@@ -30,7 +30,7 @@ export interface IContentPanelProps {
3030}
3131
3232export 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