Skip to content

fix data viewer multi-cell copy and horizontal scrollbar on tab return - #17804

Merged
kevinushey merged 1 commit into
mainfrom
bugfix/17800-dataviewer-scrollbar-copy
May 30, 2026
Merged

kevinushey merged 1 commit into
mainfrom
bugfix/17800-dataviewer-scrollbar-copy

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Intent

Addresses #17800.

Two regressions in the vanilla-JS data viewer (introduced by the rewrite in #17382):

  1. Horizontal scrollbar disappears after returning to the tab. The grid uses auto-hide overlay scrollbars that fade after ~1.2s and only reappear on a scroll event. Returning to the data viewer tab re-ran layout (onActivate) but never re-showed the bars, so the horizontal scrollbar stayed hidden -- and since horizontal scrolls rarely happen via the wheel, it was effectively gone until the user arrow-keyed a cell out of view.

  2. Ctrl/Cmd+C only copied the active cell. While the viewport is focused the grid intercepts copy to grab the single active cell, but it did so unconditionally and preventDefault()ed the keystroke -- clobbering any multi-cell native text selection. Copying multiple cells only worked when the viewer was popped out to a separate window (where focus isn't forced onto the viewport).

Changes

  • DataViewer.js: call showScrollbars() from onActivate and onResize so the auto-hide bars resurface after a relayout (update() still leaves non-scrollable axes hidden).
  • DataViewer.js: in the copy handler, defer to the browser's native copy when a non-empty selection exists; the single-active-cell copy remains the fallback when nothing is selected.

Tests

Two Playwright tests added to e2e/rstudio/tests/panes/data-viewer/data_viewer.test.ts (each fails on the pre-fix code):

  • multi-cell selection + Ctrl/Cmd+C fires a native copy carrying both cells
  • horizontal scrollbar regains its visible class after switching away and back to the viewer tab

Full data viewer file is green (9/9) on Desktop; npm run typecheck clean.

@kevinushey kevinushey added this to the Blue Plumbago milestone May 29, 2026
@posit-snyk-bot

posit-snyk-bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@kevinushey
kevinushey requested a review from gtritchie May 29, 2026 23:58

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kevinushey
kevinushey merged commit be88754 into main May 30, 2026
8 checks passed
@kevinushey
kevinushey deleted the bugfix/17800-dataviewer-scrollbar-copy branch May 30, 2026 18:04
kevinushey added a commit that referenced this pull request Jun 1, 2026
Moving these changes to a fresh branch via a file copy reverted three
blocks that #17804 (#17800 fix) had landed on main, since the copied file
predated that PR. Restore them:

- showScrollbars() in onResize and window.onActivate
- the multi-cell native-selection guard in onGridKeyDown's copy path

Also address review feedback on the canvas sparkline:

- return null when getContext("2d") yields no context, instead of a
  wrapper around an un-drawable canvas that still shows a hover tooltip
- drop the empty .sidebar-sparkline placeholder when no sparkline is
  produced, so it doesn't reserve vertical space
kevinushey added a commit that referenced this pull request Jun 2, 2026
* fix slow data viewer when the summary panel is shown

The summary sidebar built one SVG <rect> per histogram bin for every
numeric column (hundreds of vector nodes across a wide frame) and never
isolated the grid/sidebar onto their own paint layers. Scrolling the grid
invalidated the root layer and forced all of those SVG sparklines to
repaint each frame, producing multi-second stalls -- which is why turning
the summary panel off restored responsiveness (#17806).

- Add `contain: layout paint` to #gridViewport and #sidebarContent so the
  virtual-scroll DOM churn stays local and no longer repaints the sidebar.
- Render each column's histogram to a single <canvas> instead of per-bin
  SVG <rect> nodes; the hover tooltip is preserved.
- Defer sparkline drawing until the summary panel is actually visible, so
  a hidden panel never pays the rendering cost.

Addresses #17806.

* restore per-bar hover highlight in sparklines

The canvas sparkline lost the SVG version's per-bar :hover highlight.
Redraw the canvas on hover with the hovered bar at full opacity, tracking
the hovered bin so it only repaints when the cursor crosses into a
different bar, and clear it on mouse-leave.

* restore #17804 changes clobbered by branch move; harden sparkline

Moving these changes to a fresh branch via a file copy reverted three
blocks that #17804 (#17800 fix) had landed on main, since the copied file
predated that PR. Restore them:

- showScrollbars() in onResize and window.onActivate
- the multi-cell native-selection guard in onGridKeyDown's copy path

Also address review feedback on the canvas sparkline:

- return null when getContext("2d") yields no context, instead of a
  wrapper around an un-drawable canvas that still shows a hover tooltip
- drop the empty .sidebar-sparkline placeholder when no sparkline is
  produced, so it doesn't reserve vertical space

* data viewer: virtualize columns to fix wide-frame freeze

Render only the columns intersecting the horizontal viewport (plus the always-rendered pinned columns), mirroring the existing row virtualization, with left/right spacer cells preserving the table's total width and scrollbar. Wide frames materialized ~200 columns x ~100 rows of cells in a single DOM write, and the compositor commit for that many cells stalled the main thread for several seconds. Purely client-side; the column-paging data contract is unchanged.

Also restore a column's per-column filter display when its header is recreated as it scrolls back into the window, trim the row overscan, and add an e2e test covering the filter round-trip.

Addresses #17806.

* add PW_DEBUG harness for interactive renderer profiling

PW_DEBUG opens Chromium DevTools on the dev desktop build and parks each test (via readline in the RStudio Console) so a human can arm the Performance profiler before the test drives its scenario. No-op without PW_DEBUG.

Adds a rstudio-console-waiting-for-input class on the console input (set when R requests interactive input, e.g. readline/menu/scan) so the pause can tell 'waiting for the user' apart from 'idle' -- the console clears its busy state on any prompt.

developer-only tooling; no user-facing behavior change.

* desktop: enable middle-click autoscroll

Enable the MiddleClickAutoscroll Blink feature, which Chrome and Firefox ship enabled by default but Electron does not -- so middle-click in scrollable areas (e.g. the data viewer) did nothing in RStudio Desktop.

* data viewer: clear injected header-UI state on grid teardown

activeHeaderUIs (the filter/column-type re-injection registry used as the column window slides) was module state that survived resetGridState, so it could re-inject header controls into a reset/refreshed grid even when the frontend considered them off. Clear it on teardown, and record header-UI visibility in postInitActions unconditionally so column-pagination persistence flows through that replay channel (the source of truth across bootstraps) rather than relying on the leaked registry.

Addresses #17806 (roborev review).

* e2e: de-flake the data viewer column-filter test

The open-and-type relied on page.keyboard after the 'All' click's implicit focus, and the text filter auto-dismisses (reverts to 'All') if its input blurs while empty -- so a focus hiccup between opening and typing silently dropped the keystroke or closed the editor. Type through the input locator and retry the open-and-type as a unit until the value sticks; gate on the input value before the downstream filtered-row assertion. Stable across --repeat-each=5.

* data viewer: memoize column offsets to cut per-row render cost

columnOffsets() rebuilt an O(columns) prefix sum on every call, including
once per rendered row in appendWindowedCells. Cache the result and invalidate
it alongside the pinned-offsets cache (same columnOrder + measuredWidths
dependencies), turning a full rebuild's offset work from O(rows x columns) into
O(columns) per render pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants