@@ -171,6 +171,9 @@ class ViewPage extends React.Component<ViewPageProps> {
171
171
172
172
private listRef = React . createRef < ViewEventList > ( ) ;
173
173
private splitPaneRef = React . createRef < SplitPane > ( ) ;
174
+
175
+ @observable
176
+ private shouldRestoreViewStateOnRefSet = false ;
174
177
175
178
@observable
176
179
private searchFiltersUnderConsideration : FilterSet | undefined ;
@@ -248,10 +251,8 @@ class ViewPage extends React.Component<ViewPageProps> {
248
251
if ( this . props . eventId && this . selectedEvent ) {
249
252
this . onScrollToCenterEvent ( this . selectedEvent ) ;
250
253
} else if ( ! this . props . eventId && this . props . uiStore . selectedEventId ) {
251
- // If no URL eventId but we have a persisted selection, restore it
252
- setTimeout ( ( ) => {
253
- this . listRef . current ?. restoreViewState ( ) ;
254
- } , 100 ) ;
254
+ // If no URL eventId but we have a persisted selection, restore it when ref is set
255
+ this . shouldRestoreViewStateOnRefSet = true ;
255
256
} else {
256
257
this . onScrollToEnd ( ) ;
257
258
}
@@ -333,9 +334,6 @@ class ViewPage extends React.Component<ViewPageProps> {
333
334
} )
334
335
) ;
335
336
}
336
- componentWillUnmount ( ) {
337
- // Component is unmounting
338
- }
339
337
340
338
componentDidUpdate ( prevProps : ViewPageProps ) {
341
339
// Only clear persisted selection if we're explicitly navigating to a different event via URL
@@ -468,7 +466,7 @@ class ViewPage extends React.Component<ViewPageProps> {
468
466
contextMenuBuilder = { this . contextMenuBuilder }
469
467
uiStore = { this . props . uiStore }
470
468
471
- ref = { this . listRef }
469
+ ref = { this . setListRef }
472
470
/>
473
471
</ LeftPane >
474
472
< PaneOuterContainer
@@ -642,6 +640,19 @@ class ViewPage extends React.Component<ViewPageProps> {
642
640
onScrollToEnd ( ) {
643
641
this . listRef . current ?. scrollToEnd ( ) ;
644
642
}
643
+
644
+ @action . bound
645
+ setListRef = ( ref : ViewEventList | null ) => {
646
+ if ( ref ) {
647
+ ( this . listRef as any ) . current = ref ;
648
+ if ( this . shouldRestoreViewStateOnRefSet ) {
649
+ this . shouldRestoreViewStateOnRefSet = false ;
650
+ ref . restoreViewState ( ) ;
651
+ }
652
+ } else {
653
+ ( this . listRef as any ) . current = null ;
654
+ }
655
+ } ;
645
656
}
646
657
647
658
const LeftPane = styled . div `
0 commit comments