Skip to content

limit data viewer horizontal overscroll - #17616

Merged
kevinushey merged 4 commits into
rel-golden-wattlefrom
bugfix/17612-data-viewer-overscroll
May 14, 2026
Merged

kevinushey merged 4 commits into
rel-golden-wattlefrom
bugfix/17612-data-viewer-overscroll

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Intent

Addresses #17612.

Summary

  • Cap the data viewer's horizontal overscroll padding so the rightmost column stays on-screen at maximum scroll; previously the user could scroll every unpinned column off-screen, leaving only the pinned columns (and empty padding) visible.
  • The side-by-side-with-pinned intent is preserved: at maximum scroll, the last column now sits right next to the pinned columns.
  • Sync paddingRight and the custom scrollbar thumb at the end of a column-resize drag. applyResizeDelta intentionally skips this on every mousemove to avoid jank (200+ DOM writes plus several layout reads per frame); doing it once at end of drag is enough to keep the overscroll padding and scrollbar matched to the new column widths.

Test plan

  • Reproduce the original issue: View(data.frame(matrix(1:1000000, nrow = 100000, ncol = 500))), scroll horizontally to the right edge, confirm the last column (X500) remains visible adjacent to the rownames column instead of scrolling out of sight.
  • With multiple pinned columns, scroll to the right edge and confirm the last column lands next to the pinned block (not in the middle of the viewport, not off-screen).
  • Narrow viewport so only the rownames column fits comfortably; confirm overscroll degrades to 0 rather than going negative.
  • All columns pinned: confirm no overscroll padding is applied (no phantom scrollbar).
  • Resize a column wider than the viewport; release; confirm the scrollbar thumb and overscroll padding immediately reflect the new width without needing to scroll first.
  • Click (without dragging) on a column resizer and release; confirm no spurious re-layout (didResize gate).

@kevinushey kevinushey added this to the Golden Wattle milestone May 12, 2026
@kevinushey
kevinushey requested a review from gtritchie May 12, 2026 22:08
@posit-snyk-bot

posit-snyk-bot commented May 12, 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.

@gtritchie

Copy link
Copy Markdown
Member

Automated review summary

Reviewed by three specialized agents (general code review, silent-failure / error-handling, comment accuracy). Overall: the change is small, well-scoped, and correct. A handful of low-priority observations below — none blocking.

Correctness (verified)

  • Overscroll formula edge cases all check out:
    • Zero columns: pre-existing totalTableWidth === 0 early return at DataViewer.js:942 covers it.
    • All-pinned: columnOrder[lastIdx] is pinned, lastUnpinnedWidth = 0, reducing to the previous overscroll-for-pinned-block-only behavior. Correct (no unpinned column to keep visible).
    • Single unpinned column: reserves its width, holding it adjacent to the pinned block. This is the intended fix.
    • Narrow viewport where pinned.totalWidth + lastUnpinnedWidth > viewport.clientWidth: Math.max(0, …) at L981 clamps to 0, so no negative paddingRight.
  • thead.children[i] ↔ columnOrder[i] alignment: enforced by rebuildHeaders (L883–887) via in-order appendChild, and already relied on by the existing loop at L946–948. The new code uses the same indexing — consistent.
  • The applyPinnedColumns() + updateCustomScrollbars() pairing in endResize mirrors the existing pattern in toggleSidebar (L2424/L2427).
  • didResize gate: sufficient. If didResize is false, no widths changed, so pinned offsets and scrollbar thumb are still accurate.
  • The new lastTh.offsetWidth read at L980 doesn't add a new layout-flush concern — applyPinnedColumns already performs offsetWidth reads via getPinnedOffsets() at L927. All callers are user-action paths (rebuildHeaders, endResize, debounced onResize, toggleSidebar, initGrid, onActivate) — none are scroll handlers.

Comments — minor precision (non-blocking)

  • DataViewer.js:1178–1182: the "200+ DOM writes plus layout reads per frame" figure is accurate for the 500-column repro in the test plan, but overstates the cost at typical column counts. applyPinnedColumns does roughly 4 style writes per column plus one offsetWidth read on the last unpinned <th> and a paddingRight write, so the "200+" threshold sits around ~50 columns. Consider a qualitative phrasing like "per-column style writes scale with column count, plus scrollbar layout reads." The load-bearing claim ("to avoid jank") is fine.
  • DataViewer.js:971: the trailing "(issue Data viewer lets you scroll all columns out of view #17612)" reference is borderline — global conventions discourage in-code ticket refs (they rot when the issue is closed/renumbered), but this file already uses the same style elsewhere, so this is consistent with surrounding code. Up to you whether to drop it.

Defensive-programming suggestions (intentionally not raised)

The silent-failure scan flagged adding try/catch around the new applyPinnedColumns()/updateCustomScrollbars() calls in endResize, and adding a log when thead.children.length !== columnOrder.length. Both go against the project guidance to not add error handling for scenarios that can't happen — the index alignment is an invariant maintained by rebuildHeaders, and the existing applyPinnedColumns + updateCustomScrollbars callsites elsewhere in the file also run unguarded. Leaving the diff as-is is consistent with the surrounding code.

Verdict

LGTM. Suggested follow-ups are presentation-level and optional.

@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!

Reserve room for the rightmost column when computing the table's
horizontal overscroll padding so it stays visible at maximum scroll;
previously the user could scroll every unpinned column off-screen.
Also sync paddingRight and the custom scrollbar thumb at the end of a
column resize drag (applyResizeDelta intentionally skips these on every
mousemove to avoid jank).

Addresses #17612.
Drop the totalTableWidth > viewport.clientWidth gate so the overscroll
padding is computed even when all columns fit in the viewport. This
keeps horizontal scrolling consistently available regardless of how
wide the table is relative to the viewport.
When every column is pinned (or no columns exist) there is no column
to scroll into view, so the overscroll formula would add
viewport.clientWidth - pinned.totalWidth of right padding for nothing,
producing a phantom horizontal scrollbar and shrinking the body.

getColumnOrder() places pinned columns before unpinned, so the last
columnOrder entry being unpinned is sufficient to confirm an unpinned
column exists. Gate the overscroll computation on that check; otherwise
leave overscroll = 0.
@kevinushey
kevinushey force-pushed the bugfix/17612-data-viewer-overscroll branch from 5a24291 to cfd16b7 Compare May 13, 2026 21:39
@kevinushey
kevinushey changed the base branch from main to rel-golden-wattle May 13, 2026 21:39
@kevinushey
kevinushey merged commit f564cd3 into rel-golden-wattle May 14, 2026
8 checks passed
@kevinushey
kevinushey deleted the bugfix/17612-data-viewer-overscroll branch May 14, 2026 15:49
kevinushey added a commit that referenced this pull request May 14, 2026
* update BUILDTYPE to Release for Golden Wattle

* archive NEWS for golden wattle (#17623)

* trim "What's New" section for Golden Wattle release (#17629)

* limit data viewer horizontal overscroll (#17616)

* limit data viewer horizontal overscroll

Reserve room for the rightmost column when computing the table's
horizontal overscroll padding so it stays visible at maximum scroll;
previously the user could scroll every unpinned column off-screen.
Also sync paddingRight and the custom scrollbar thumb at the end of a
column resize drag (applyResizeDelta intentionally skips these on every
mousemove to avoid jank).

Addresses #17612.

* always allow horizontal overscroll in data viewer

Drop the totalTableWidth > viewport.clientWidth gate so the overscroll
padding is computed even when all columns fit in the viewport. This
keeps horizontal scrolling consistently available regardless of how
wide the table is relative to the viewport.

* skip data viewer overscroll padding when no unpinned columns

When every column is pinned (or no columns exist) there is no column
to scroll into view, so the overscroll formula would add
viewport.clientWidth - pinned.totalWidth of right padding for nothing,
producing a phantom horizontal scrollbar and shrinking the body.

getColumnOrder() places pinned columns before unpinned, so the last
columnOrder entry being unpinned is sufficient to confirm an unpinned
column exists. Gate the overscroll computation on that check; otherwise
leave overscroll = 0.

* add NEWS entry

* data viewer: restore column count in status bar (#17617)

* data viewer: restore column count in status bar

Addresses #17613.

The vanilla-JS data viewer rewrite dropped the column count from the
info bar. Reword the info text to include it, and use "rows" instead
of "entries" so it pairs cleanly with "columns".

* data viewer: keep 'entries' wording in info bar

* data viewer: restore 'total' qualifier in info bar text

Reverts an unintended wording change that dropped 'total' from the
column count, which broke the Playwright assertions in
pagination-sorting.test.ts. Also adds 'entries' to the filtered
suffix for clarity.

* add NEWS entry

* preserve top alignment of help argument names with r-devel (#17622)

Broaden the <h3>Arguments</h3> match so it also handles the id attribute
emitted by R >= 4.6.0 when the dynamic help server includes a table of
contents (the default in r-devel). Without this, the r-arguments-title
class is never added and the CSS rule that top-aligns argument names
never applies.

Addresses #17621.

* add scripts/merge-release-branch.sh

Wraps `git merge --no-ff -X no-renames <branch>` plus the post-merge
fixups needed for a rel-* -> main merge:

- Auto-resolve NEWS.md modify/delete by keeping main's version.
- Auto-resolve version/news/os/NEWS-<ver>-<codename>.md add/add by taking
  the rel branch's content (which has any bug-fix entries added after the
  rotation).
- Reset version/BUILDTYPE, version/RELEASE, version/CALENDAR_VERSION to
  HEAD's values to undo git's trivial-merge fast-take in cases where main
  has not modified the file (most notably BUILDTYPE, which silently flips
  Daily -> Release without intervention).

Stages the merge but does not commit it -- the user reviews with
`git diff --staged` and then runs `git commit`.

The earlier attempt to handle BUILDTYPE via a `merge=ours` driver in
.gitattributes does not work for this scenario: git only consults merge
drivers for true three-way merges (where both sides modified the file),
not for the one-sided trivial merge that BUILDTYPE actually hits.

* restore main's full whats-new/golden-wattle/index.html

The merge of rel-golden-wattle into main applied the trim from #17629,
which curated the What's New content for the release announcement.
Revert that on main so main retains the full pre-trim content; the
trimmed version remains on the rel branch where it ships.

---------

Co-authored-by: Skye Turriff <[email protected]>
Co-authored-by: Gary Ritchie <[email protected]>
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