@@ -892,11 +892,13 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
892892 if ( ! listWindow ) return true ; // This means no rows, so we are effectively at the bottom
893893 else return ( listWindow . scrollTop + SCROLL_BOTTOM_MARGIN ) >= ( listWindow . scrollHeight - listWindow . offsetHeight ) ;
894894 }
895+
895896 private wasListAtBottom = true ;
897+
896898 private updateScrolledState = ( ) => {
897899 requestAnimationFrame ( ( ) => { // Measure async, once the scroll has actually happened
898900 this . wasListAtBottom = this . isListAtBottom ( ) ;
899-
901+
900902 // Only save scroll position after we've restored the initial state
901903 if ( this . hasRestoredInitialState ) {
902904 const listWindow = this . listBodyRef . current ?. parentElement ;
@@ -908,7 +910,7 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
908910 }
909911
910912 private hasRestoredInitialState = false ;
911-
913+
912914 componentDidUpdate ( prevProps : ViewEventListProps ) {
913915 if ( this . listBodyRef . current ?. parentElement ?. contains ( document . activeElement ) ) {
914916 // If we previously had something here focused, and we've updated, update
@@ -919,7 +921,7 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
919921 // If we previously were scrolled to the bottom of the list, but now we're not,
920922 // scroll there again ourselves now.
921923 if ( this . wasListAtBottom && ! this . isListAtBottom ( ) ) {
922- this . listRef . current ?. scrollToItem ( this . props . events . length - 1 ) ;
924+ this . listRef . current ?. scrollToItem ( this . props . events . length - 1 ) ;
923925 } else if ( prevProps . selectedEvent !== this . props . selectedEvent && this . props . selectedEvent ) {
924926 // If the selected event changed and we have a selected event, scroll to it
925927 // This handles restoring the selected event when returning to the tab
@@ -937,7 +939,8 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
937939 const savedPosition = this . props . uiStore . viewScrollPosition ;
938940 if ( savedPosition > 0 ) {
939941 const listWindow = this . listBodyRef . current ?. parentElement ;
940- if ( listWindow ) { // Only restore if we're not close to the current position (avoid unnecessary scrolling)
942+ if ( listWindow ) {
943+ // Only restore if we're not close to the current position (avoid unnecessary scrolling)
941944 if ( Math . abs ( listWindow . scrollTop - savedPosition ) > 10 ) {
942945 listWindow . scrollTop = savedPosition ;
943946 }
@@ -1045,7 +1048,9 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
10451048 }
10461049
10471050 event . preventDefault ( ) ;
1048- } // Public method to force scroll and selection restoration
1051+ }
1052+
1053+ // Public method to force scroll and selection restoration
10491054 public restoreViewState = ( ) => {
10501055 if ( this . props . selectedEvent ) {
10511056 this . scrollToEvent ( this . props . selectedEvent ) ;
0 commit comments