@@ -772,11 +772,11 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
772
772
private setListBodyRef = ( element : HTMLDivElement | null ) => {
773
773
// Update the ref
774
774
( this . listBodyRef as any ) . current = element ;
775
-
775
+
776
776
// If the element is being mounted and we haven't restored state yet, do it now
777
- if ( element && ! this . hasRestoredInitialState ) {
777
+ if ( element && ! this . hasRestoredScrollState ) {
778
778
this . restoreScrollPosition ( ) ;
779
- this . hasRestoredInitialState = true ;
779
+ this . hasRestoredScrollState = true ;
780
780
}
781
781
} ;
782
782
@@ -900,16 +900,20 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
900
900
this . wasListAtBottom = this . isListAtBottom ( ) ;
901
901
902
902
// Only save scroll position after we've restored the initial state
903
- if ( this . hasRestoredInitialState ) {
903
+ if ( this . hasRestoredScrollState ) {
904
904
const listWindow = this . listBodyRef . current ?. parentElement ;
905
+
906
+ const scrollPosition = this . wasListAtBottom
907
+ ? 'end'
908
+ : ( listWindow ?. scrollTop ?? 'end' ) ;
905
909
if ( listWindow ) {
906
- this . props . uiStore . setViewScrollPosition ( listWindow . scrollTop ) ;
910
+ this . props . uiStore . setViewScrollPosition ( scrollPosition ) ;
907
911
}
908
912
}
909
913
} ) ;
910
914
}
911
915
912
- private hasRestoredInitialState = false ;
916
+ private hasRestoredScrollState = false ;
913
917
914
918
componentDidUpdate ( prevProps : ViewEventListProps ) {
915
919
if ( this . listBodyRef . current ?. parentElement ?. contains ( document . activeElement ) ) {
@@ -930,11 +934,12 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
930
934
}
931
935
932
936
private restoreScrollPosition = ( ) => {
933
- // Only restore if we have a saved position
934
937
const savedPosition = this . props . uiStore . viewScrollPosition ;
935
- if ( savedPosition > 0 ) {
936
- const listWindow = this . listBodyRef . current ?. parentElement ;
937
- if ( listWindow ) {
938
+ const listWindow = this . listBodyRef . current ?. parentElement ;
939
+ if ( listWindow ) {
940
+ if ( savedPosition === 'end' ) {
941
+ listWindow . scrollTop = listWindow . scrollHeight ;
942
+ } else {
938
943
// Only restore if we're not close to the current position (avoid unnecessary scrolling)
939
944
if ( Math . abs ( listWindow . scrollTop - savedPosition ) > 10 ) {
940
945
listWindow . scrollTop = savedPosition ;
@@ -1044,13 +1049,4 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
1044
1049
1045
1050
event . preventDefault ( ) ;
1046
1051
}
1047
-
1048
- // Public method to force scroll and selection restoration
1049
- public restoreViewState = ( ) => {
1050
- if ( this . props . selectedEvent ) {
1051
- this . scrollToEvent ( this . props . selectedEvent ) ;
1052
- } else {
1053
- this . restoreScrollPosition ( ) ;
1054
- }
1055
- }
1056
1052
}
0 commit comments