Repository navigation
persist data viewer scroll position across reloads - #17887
Merged
Merged
Conversation
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.
🍎 macOS Desktop E2E · ARM64✅ All tests passed!
📥 Download Playwright report⬇️ playwright-report.zip — extract and open
2 shards · macos-26 ARM64 · commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The data viewer already persists per-object UI state (pinned columns, sorts, filters, sidebar visibility, column widths) to
localStorageso it survives a reload / suspend-restore, and clears it on an explicit close. This extends that persisted state to include the scroll position, so reopening a data set returns you to where you were scrolled rather than the top.What changed
src/cpp/session/resources/grid/DataViewer.js:saveState()recordsscroll: { 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). Also guards against saving before the grid is initialized.applySavedState()seeds the existingactiveScrollRestoreslot from the saved scroll. The restore then flows throughrestoreScrollAfterRefreshafter the first row fetch, which re-checks the row count and defers to any live refresh-driven capture. Only runs once the column fingerprint matches.onScrollEnd/onDeactivatecallsaveState()so the persisted position stays current.Clearing on close needs no new code: scroll rides in the same
localStorageentry the close path already removes (host-side clear +onDismiss).STATE_VERSIONis intentionally left at 3 -- adding an optional field is backward-compatible, and bumping would have discarded users' existing pins/sorts/filters for a purely additive change.Testing
Added an e2e test (
scroll position is restored after a reload) that scrolls down, confirms the offset persisted to the shared host/iframelocalStorage, reloads the data viewer iframe, and asserts the position is restored. The full data-viewer Playwright suite (19 tests) passes locally with no regressions.Follow-on to the data viewer state-persistence work in #17861 and #17886.