Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 286ef4f

Browse files
authored
Fix scrolling (microsoft#5747)
1 parent 34ed3fd commit 286ef4f

File tree

3 files changed

+46
-37
lines changed

3 files changed

+46
-37
lines changed

news/2 Fixes/5560.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Change scrolling to not animate to workaround async updates breaking the animation.

package-lock.json

+39-21
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

+6-16
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface IContentPanelProps {
3030
}
3131

3232
export class ContentPanel extends React.Component<IContentPanelProps> {
33-
private bottom: HTMLDivElement | undefined;
33+
private bottomRef: React.RefObject<HTMLDivElement> = React.createRef<HTMLDivElement>();
3434
constructor(prop: IContentPanelProps) {
3535
super(prop);
3636
}
@@ -51,7 +51,7 @@ export class ContentPanel extends React.Component<IContentPanelProps> {
5151
{this.renderCells()}
5252
</div>
5353
</div>
54-
<div ref={this.updateBottom}/>
54+
<div ref={this.bottomRef}/>
5555
</div>
5656
);
5757
}
@@ -88,20 +88,10 @@ export class ContentPanel extends React.Component<IContentPanelProps> {
8888
}
8989

9090
private scrollToBottom = () => {
91-
if (this.bottom && this.bottom.scrollIntoView && !this.props.skipNextScroll && !this.props.testMode) {
92-
// Delay this until we are about to render. React hasn't setup the size of the bottom element
93-
// yet so we need to delay. 10ms looks good from a user point of view
94-
setTimeout(() => {
95-
if (this.bottom) {
96-
this.bottom.scrollIntoView({behavior: 'smooth', block : 'end', inline: 'end'});
97-
}
98-
}, 100);
99-
}
100-
}
101-
102-
private updateBottom = (newBottom: HTMLDivElement) => {
103-
if (newBottom !== this.bottom) {
104-
this.bottom = newBottom;
91+
if (this.bottomRef.current && !this.props.skipNextScroll && !this.props.testMode) {
92+
// Force auto here as smooth scrolling can be canceled by updates to the window
93+
// from elsewhere (and keeping track of these would make this hard to maintain)
94+
this.bottomRef.current.scrollIntoView({behavior: 'auto', block: 'start', inline: 'nearest'});
10595
}
10696
}
10797

0 commit comments

Comments
 (0)