Repository navigation
fix data viewer remembering filters and sorts across close/reopen - #17886
Conversation
Review SummaryReviewed across general code quality, test coverage, error handling, and comment accuracy. No critical or blocking issues — the design holds up: the same-origin localStorage assumption, the close-vs-move gating, the host-side-clear ordering, and the dual-sync callback pattern all check out. One test gap is worth acting on. Important1. The close-vs-move distinction has zero test coverage. This is the central correctness invariant of the fix. Suggestions2. Suspend/restore preservation is asserted in NEWS but only approximated in tests. The reload test is a reasonable proxy, but actual session suspend/restore is a distinct teardown path (the tab widget is torn down and rebuilt) and is the behavior NEWS.md explicitly promises. Nice-to-have. 3. 4. Silent un-cleared state if the iframe never finished loading before close. If the user opens and closes the viewer before the iframe 5. Minor: the diff shows spurious deletions. The branch is one commit behind |
gtritchie
left a comment
There was a problem hiding this comment.
LGTM! Mr. C has some ideas on additional tests, comment tweaks, etc.
🍎 macOS Desktop E2E · ARM64✅ All tests passed!
📥 Download Playwright report⬇️ playwright-report.zip — extract and open
2 shards · macos-26 ARM64 · commit |
The data viewer rewrite persists per-object UI state (sorts, filters, pins) to localStorage. Two problems with how that state is restored and cleared: - Explicitly closing a data viewer tab failed to clear the saved state, because the clear ran inside the iframe via onDismiss -- which fires from TabClosedEvent, after the tab widget (and its iframe) is already detached. getWindow() was null, so the in-frame clear silently no-oped and reopening the data set restored stale filters/sorts. The host now clears the saved-state key directly via shared same-origin localStorage (the iframe reports its key on load via stateKeyCallback), which works after the frame is gone. Close is the only teardown that clears; suspend /restore and page reload still preserve state. - Restoring a saved filter applied it to the data but left the filter row hidden, so the filter was active with no visible UI. Bootstrap now reveals the filter row when restored filters are non-empty, and a new filterStateCallback keeps the toolbar funnel latch in sync. Adds Playwright regression tests for both behaviors.
1603eec to
9138fab
Compare
The data viewer already persists per-object UI state (pinned columns,
sorts, filters, sidebar visibility, column widths) to localStorage so it
survives a reload / suspend-restore, and clears it on an explicit close.
Extend that persisted state to include the scroll position.
saveState now records scroll: { top, left, rows }, keyed to the
unfiltered row count so a frame whose size changed while closed reopens
at the top (the same guard in-place refreshes use). applySavedState
seeds the existing activeScrollRestore slot from the saved scroll, so
the restore flows through restoreScrollAfterRefresh after the first row
fetch -- which re-checks the row count and defers to any live
refresh-driven capture. onScrollEnd and onDeactivate now call saveState
so the persisted position stays current.
Clearing on close needs no new code: scroll rides in the same
localStorage entry the close path already removes.
Follow-on to the data viewer state-persistence work in #17861 and #17886.
Summary
The data viewer rewrite (#17382) persists per-object UI state (sorts, filters, pinned columns) to
localStorage. This fixes two problems with how that state is restored and cleared, reported in #17830.Saved state survived an explicit close
Closing a data viewer tab is supposed to discard its saved state, but it didn't: the clear ran inside the iframe via
window.onDismiss, which is driven byTabClosedEvent-- and that fires after the tab widget (and its iframe) has already been detached from the DOM (DocTabLayoutPanel.removecallssuper.removebefore firing the event). SogetWindow()was null and the in-frame clear silently no-oped, leaving the entry inlocalStorage. Reopening the data set then restored stale filters/sorts.The close-vs-move distinction is only known post-detach (
DISMISS_TYPE_CLOSE), so a pre-detach clear isn't an option. Instead, the iframe now reports itslocalStoragekey on load (stateKeyCallback), and on an explicit close the host clears that key directly via shared same-originlocalStorage-- which works even though the frame is gone. An explicit close is the only teardown that clears; a session suspend/restore or a page reload still preserves state (which is the intended behavior).Restored filters were applied with no visible filter UI
Restoring a saved filter sent it to the server (the rows were filtered) but left the filter row hidden, so the filter was active with no visible UI to see or edit it. Bootstrap now reveals the filter row when restored filters are non-empty (recorded as a post-init action so it survives column pagination), and a new
filterStateCallbackkeeps the toolbar funnel latch in sync -- mirroring the existingsidebarStateCallback.Tests
Adds two Playwright regression tests to
data_viewer.test.ts:localStorage), closes the tab, and asserts the key is gone.aria-pressed=true, and the data is still filtered.All 18 tests in the file pass (16 existing + 2 new).
Fixes #17830