Skip to content

Commit 09c6c2d

Browse files
authored
Merge pull request #5811 from microsoft/rchiodo/release_3
Fix latex and markdown scrolling
2 parents 06b62a0 + 04b4e79 commit 09c6c2d

File tree

3 files changed

+28
-36
lines changed

3 files changed

+28
-36
lines changed

news/2 Fixes/5775.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix latex and markdown scrolling.

package-lock.json

Lines changed: 19 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datascience-ui/history-react/contentPanel.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface IContentPanelProps {
3131

3232
export class ContentPanel extends React.Component<IContentPanelProps> {
3333
private bottomRef: React.RefObject<HTMLDivElement> = React.createRef<HTMLDivElement>();
34+
private containerRef: React.RefObject<HTMLDivElement> = React.createRef<HTMLDivElement>();
3435
constructor(prop: IContentPanelProps) {
3536
super(prop);
3637
}
@@ -45,7 +46,7 @@ export class ContentPanel extends React.Component<IContentPanelProps> {
4546

4647
public render() {
4748
return(
48-
<div id='content-panel-div'>
49+
<div id='content-panel-div' ref={this.containerRef}>
4950
<div id='cell-table'>
5051
<div id='cell-table-body'>
5152
{this.renderCells()}
@@ -89,10 +90,14 @@ export class ContentPanel extends React.Component<IContentPanelProps> {
8990
}
9091

9192
private scrollToBottom = () => {
92-
if (this.bottomRef.current && !this.props.skipNextScroll && !this.props.testMode) {
93+
if (this.bottomRef.current && !this.props.skipNextScroll && !this.props.testMode && this.containerRef.current) {
9394
// Force auto here as smooth scrolling can be canceled by updates to the window
9495
// from elsewhere (and keeping track of these would make this hard to maintain)
95-
this.bottomRef.current.scrollIntoView({behavior: 'auto', block: 'start', inline: 'nearest'});
96+
setTimeout(() => {
97+
if (this.bottomRef.current) {
98+
this.bottomRef.current!.scrollIntoView({behavior: 'auto', block: 'start', inline: 'nearest'});
99+
}
100+
}, 100);
96101
}
97102
}
98103

0 commit comments

Comments
 (0)