@@ -30,7 +30,7 @@ export interface IContentPanelProps {
30
30
}
31
31
32
32
export class ContentPanel extends React . Component < IContentPanelProps > {
33
- private bottom : HTMLDivElement | undefined ;
33
+ private bottomRef : React . RefObject < HTMLDivElement > = React . createRef < HTMLDivElement > ( ) ;
34
34
constructor ( prop : IContentPanelProps ) {
35
35
super ( prop ) ;
36
36
}
@@ -51,7 +51,7 @@ export class ContentPanel extends React.Component<IContentPanelProps> {
51
51
{ this . renderCells ( ) }
52
52
</ div >
53
53
</ div >
54
- < div ref = { this . updateBottom } />
54
+ < div ref = { this . bottomRef } />
55
55
</ div >
56
56
) ;
57
57
}
@@ -88,20 +88,10 @@ export class ContentPanel extends React.Component<IContentPanelProps> {
88
88
}
89
89
90
90
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' } ) ;
105
95
}
106
96
}
107
97
0 commit comments