Repository navigation
preserve data viewer scroll position and show new columns on refresh - #17883
Conversation
When a viewed object is changed in place (a column added or removed, or values edited in an existing column), the data viewer refreshes by tearing the grid down and rebuilding it, which snapped the user back to the first row. Capture the scroll position before the rebuild and restore it once the first row batch re-establishes the scrollable height -- but only when the unfiltered row count is unchanged. A changed row count signals genuinely new data (subset, reassignment, rows added/removed), so the grid still resets to the top in that case. Addresses #17861
On an in-place refresh the column fetch (buildRequestedColumns) clamped the requested column window to totalCols, but totalCols was never reset and still held the previous frame's count. A column added since (e.g. `df$new <- ...`) therefore fell outside the clamp and was never fetched, so the new column did not appear until the viewer was reopened. resetGridState already clears the sibling frame state (cols, and totalRows via invalidateCache); reset totalCols there too so the window is requested in full and the server bounds it to the real frame. resetGridState only runs from bootstrap, which always re-fetches columns and repopulates totalCols. Addresses #17861
Review summaryRan four specialized passes (general code, tests, comments, silent failures) and independently verified the contested findings against the source. One real robustness bug worth fixing, plus a few coverage gaps. Critical:
|
🍎 macOS Desktop E2E · ARM64❌ 1 test(s) failed
📥 Download Playwright report⬇️ playwright-report.zip — extract and open
2 shards · macos-26 ARM64 · commit |
Address review feedback on #17883: - bind the captured scroll position to a single rebuild via activeScrollRestore, so a refresh that aborts before its restore callback can't leak the offset onto an unrelated later bootstrap (e.g. column pagination) - guard the restore requestAnimationFrame with a drawCounter token so a rapid second refresh can't apply a stale offset - note the unfiltered-total gate / global-search edge in the restore comment - add Playwright tests for column removal and Reset View; rename the column-add test and annotate the ROW_HEIGHT slack
|
Thanks for the thorough review! Addressed in 6fc3064: Code
Tests
Deliberately skipped
All 16 data-viewer tests pass on the dev desktop build. |
Summary
When a viewed data frame is changed in place -- a column added or removed, or values edited in an existing column -- the data viewer refreshes by tearing the grid down and rebuilding it. Two things went wrong on that refresh:
destroyGridzeroes the viewport scroll and the grid rebuilt from row 1, so scrolling to row ~600 and then adding a variable snapped you back to the top.buildRequestedColumns) clamps the requested window tototalCols, buttotalColswas never reset on refresh and still held the previous frame's count -- so a column added since fell outside the clamp and was never fetched.This PR fixes both.
Changes
DataViewer.js): capture the scroll position beforebootstrap()tears the grid down, and restore it once the first row batch re-establishes the scrollable height -- but only when the unfiltered row count (recordsTotal) is unchanged. A changed row count signals genuinely new data (subset, reassignment, rows added/removed), so the grid still resets to the top in that case. "Reset View" continues to return to the top.DataViewer.js): reset the staletotalColsinresetGridState, consistent with how the sibling frame state (cols,totalRows) is already cleared. 0 means "unknown," so the window is requested in full and the server bounds it to the real frame.resetGridStateonly runs frombootstrap, which always re-fetches columns and repopulatestotalCols. Wide, column-paginated frames are unaffected:columnOffset/maxDisplayColumnsare still preserved, so the column window stays put.Testing
Two new Playwright tests in
data_viewer.test.ts, plus the existing data-viewer and pagination/sorting suites (19 tests total) all pass on the dev desktop build:Fixes #17861