@@ -892,11 +892,13 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
892
892
if ( ! listWindow ) return true ; // This means no rows, so we are effectively at the bottom
893
893
else return ( listWindow . scrollTop + SCROLL_BOTTOM_MARGIN ) >= ( listWindow . scrollHeight - listWindow . offsetHeight ) ;
894
894
}
895
+
895
896
private wasListAtBottom = true ;
897
+
896
898
private updateScrolledState = ( ) => {
897
899
requestAnimationFrame ( ( ) => { // Measure async, once the scroll has actually happened
898
900
this . wasListAtBottom = this . isListAtBottom ( ) ;
899
-
901
+
900
902
// Only save scroll position after we've restored the initial state
901
903
if ( this . hasRestoredInitialState ) {
902
904
const listWindow = this . listBodyRef . current ?. parentElement ;
@@ -908,7 +910,7 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
908
910
}
909
911
910
912
private hasRestoredInitialState = false ;
911
-
913
+
912
914
componentDidUpdate ( prevProps : ViewEventListProps ) {
913
915
if ( this . listBodyRef . current ?. parentElement ?. contains ( document . activeElement ) ) {
914
916
// If we previously had something here focused, and we've updated, update
@@ -919,7 +921,7 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
919
921
// If we previously were scrolled to the bottom of the list, but now we're not,
920
922
// scroll there again ourselves now.
921
923
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 ) ;
923
925
} else if ( prevProps . selectedEvent !== this . props . selectedEvent && this . props . selectedEvent ) {
924
926
// If the selected event changed and we have a selected event, scroll to it
925
927
// This handles restoring the selected event when returning to the tab
@@ -937,7 +939,8 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
937
939
const savedPosition = this . props . uiStore . viewScrollPosition ;
938
940
if ( savedPosition > 0 ) {
939
941
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)
941
944
if ( Math . abs ( listWindow . scrollTop - savedPosition ) > 10 ) {
942
945
listWindow . scrollTop = savedPosition ;
943
946
}
@@ -1045,7 +1048,9 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
1045
1048
}
1046
1049
1047
1050
event . preventDefault ( ) ;
1048
- } // Public method to force scroll and selection restoration
1051
+ }
1052
+
1053
+ // Public method to force scroll and selection restoration
1049
1054
public restoreViewState = ( ) => {
1050
1055
if ( this . props . selectedEvent ) {
1051
1056
this . scrollToEvent ( this . props . selectedEvent ) ;
0 commit comments