Skip to content

give the data viewer grid an overscroll tail past the last row - #18652

Merged
kevinushey merged 12 commits into
mainfrom
bugfix/18620-data-viewer-last-row-under-scrollbar
Aug 27, 2026
Merged

kevinushey merged 12 commits into
mainfrom
bugfix/18620-data-viewer-last-row-under-scrollbar

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Intent

Addresses #18620.

The report has two halves -- the Data Viewer "bounces" at the bottom of a large
frame, and the last row is blocked from view. This PR fixes the second half,
which reproduces reliably on every platform.

The bug

The Data Viewer's horizontal scrollbar is a floating overlay
(.custom-scrollbar.horizontal: bottom: 0; height: 11px inside #gridPanes),
so it covers the bottom 11px of the grid rather than taking layout space. The
virtualizer sized the bottom spacer to exactly (activeRows - newEnd - 1) * ROW_HEIGHT, so the grid's scroll content ended at the last row: at maximum
scroll that row sits flush against the viewport bottom, permanently half hidden
under the bar, with nowhere left to scroll.

visibleBodyHeight() already discounted those 11px -- that is how
ensureActiveCellVisible clears the bar for every other row. The last row was
the one target that could never reach the same place, because the scroll range
stopped 11px short of where it needed to end.

Measured in RStudio Server on macOS with `View(as.data.frame(matrix(seq_len(500

  • 30), nrow = 500)))`, scrolled to the bottom, the last row's bottom edge sits
    11px below the top of the scrollbar -- the bar covers just under half of it:
lastRow: 499  lastRowTop: 482  lastRowBottom: 505
viewportBottom: 505  scrollbarTop: 494   ->  11px occluded

The fix

Add a matching overscroll tail to the bottom spacer, so the last row can be
scrolled out from under the bar. This mirrors two affordances the grid already
has for exactly this reason: the summary sidebar's tail (renderSidebarWindow)
and the horizontal overscroll padding that keeps the rightmost column reachable
(applyPinnedColumns, #17612).

The tail is gated on overlay-scrollbar mode, since a native horizontal scrollbar
takes layout space and is already excluded from clientHeight.
visibleBodyHeight now shares that gate through the new
hScrollbarOverlayHeight() helper, instead of subtracting 11px in a mode where
nothing overlays the rows.

Two consequences of letting scrollTop run past the last row are handled:

  • the render window's start is clamped against its end, so a viewport shorter
    than the header plus the tail cannot push firstVisible off the end of the
    frame and render an empty window;
  • the tail is part of the render window's identity (renderOverscroll), so a
    change in horizontal overflow re-sizes the spacer even when the row window is
    unchanged.

The "bounce" half

I could not reproduce a moving scroll position on macOS, in either RStudio
Server or a standalone harness driving the real grid resources. Ruled out with
measurements: the pinned-pane/viewport scroll mirror (Blink drains newly
enqueued scroll events in the same dispatch pass, so onPinnedScroll never
observes a stale mirror -- 356 events during a smooth scroll, 0 mismatches),
scroll anchoring (already opted out in #18222), scrollHeight instability,
fetch-driven relayout, device pixel ratios 1-2, and page zoom 0.8-2.

Both previous bugs in this component (#18221, #18378) were Windows/RHEL-only, so
this one likely is too. The new test asserts the scroll position settles at the
bottom as well as the geometry, so the Windows CI matrix will report on that
half the way it did for #18378.

Testing

New e2e test the last row clears the horizontal scrollbar at maximum scroll (#18620) in data_viewer.test.ts: views a 500x30 frame so both axes overflow,
wheels to the bottom, and asserts the scroll settles, the last row is rendered
inside the viewport, and its bottom edge clears the top of the scrollbar.

Verified against a session serving each version of the grid resources:

  • with the fix: passes (last row bottom == scrollbar top)
  • without it: fails on the scrollbar assertion -- Expected: <= 108.5, Received: 119, i.e. the 11px overlap

The full tests/panes/data-viewer/ suite passes (66 tests).

The custom horizontal scrollbar floats over the bottom 11px of the grid
panes rather than taking layout space, and renderVisibleRows sized the
bottom spacer to exactly the rows left below the window -- so the grid's
scroll range ended with the last row flush against the viewport bottom,
permanently half covered by the bar with nowhere left to scroll.

visibleBodyHeight already discounted those 11px, which is how
ensureActiveCellVisible clears the bar for every other row; the last row
was the one target that could never reach the same place.

Add a matching overscroll tail to the bottom spacer, mirroring the
summary sidebar's tail (renderSidebarWindow) and the horizontal
overscroll padding that keeps the rightmost column reachable
(applyPinnedColumns). The tail is gated on overlay-scrollbar mode, since
a native horizontal scrollbar takes layout space and is already excluded
from clientHeight -- visibleBodyHeight now shares that gate too, instead
of subtracting 11px in a mode where nothing overlays the rows.

Because the tail lets scrollTop run past the last row, clamp the render
window's start against its end so a very short viewport can't push it
off the end of the frame, and fold the tail into the window identity so
a change in horizontal overflow re-sizes the spacer on its own.

Addresses #18620.
@github-actions

github-actions Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

#################### 100% pass rate

Passed Failed Skipped Flaky
2430 0 152 1
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 10 0
✅ desktop-linux 603 0 31 0
✅ desktop-macos 609 0 26 0
✅ desktop-windows 608 0 31 1
✅ server-linux 582 0 44 0
✅ setup 26 0 10 0
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit 5ae273b7ebdbc3165f8f121cbaacfcfbdede283c - Run #728

hScrollbarOverlayHeight assumed a native horizontal scrollbar always takes
layout space and is therefore already excluded from clientHeight. That holds
on Windows and Linux, but not on macOS, where native bars are overlays by
default ("Show scroll bars: When scrolling") and clientHeight still spans the
strip underneath. Returning 0 there re-opened the bottom-edge case #17958
fixed -- ensureActiveCellVisible would leave the last row half covered, and
updateInfoBar would count an occluded row as visible.

Measure the gutter instead: the scroll panes carry no border, so
offsetHeight - clientHeight is exactly the space the native bar claimed, and
zero means it floats like ours does. The overscroll tail now applies in that
configuration too, which is where it is equally needed.

Also drop the last hand-written 11 alongside the new constant: the vertical
overlay bar's bottom inset re-implemented the same overflow test, which is
the duplication H_SCROLLBAR_HEIGHT was introduced to remove.

The e2e geometry read ran off whichever row was last rendered; the
full-rebuild path stops at the first row missing from the block cache, so
wait for row 499 to be attached before measuring.
hScrollbarOverlayHeight now feeds both visibleBodyHeight and the bottom
spacer's overscroll tail, and its answer changes when the scrollbar mode
flips. applyScrollbarMode created or destroyed the overlay bars and updated
them, but never re-rendered the window, so an overlay -> native switch on an
open grid left an 11px dead-scroll tail past the last row until some
unrelated event forced a rebuild. Every other site that can change
horizontal-overflow state (onResize, toggleSidebar, column resize end, filter
row toggle, tab activation) already pairs the two.

Cover the native path in the e2e suite: the grid is opened in overlay mode,
the preference is flipped on the open grid (the setOption path that has to
re-render), and the last row's bottom edge is asserted against the viewport's
measured gutter -- flush with the client box where the native bar takes
layout space, a tail's height clear of it where the platform draws the bar as
an overlay. That pins whichever branch the host runs.

Also note the second, approximate use of H_SCROLLBAR_HEIGHT in its doc
comment, and reword the newStart clamp comment: with BUFFER_ROWS = 25 and a
tail only a couple of rows tall the clamp is defensive, not a live case.
…n the test

The switch changes visibleBodyHeight in both directions at once -- the 11px
overlay discount disappears while clientHeight shrinks by the native gutter --
and updateInfoBar derives the "Showing X to Y" range from it, so the range
stayed a row off until the next scroll. onResize already pairs the two for
the same class of change.

The e2e test did not actually pin the re-render it was written for: every
assertion came after eight wheel events, and the incremental render path
repairs a stale tail on its own (the skip check compares overscroll against
renderOverscroll). Read the scroll range immediately after the flip instead,
before any scroll input, and assert it loses exactly the tail where the
native bar takes layout space and keeps it where the platform overlays.

Also gate the test on horizontal overflow rather than on the bar being in the
DOM: attachCustomScrollbar leaves the element attached and only sets
display:none when the axis doesn't overflow, so on a host wide enough to fit
30 columns a correct 0 tail would have failed as a tail mismatch.
…ding

applyScrollbarMode also runs from initGrid, after installColumnResponse has
set totalRows but before the first block has set filteredRows. updateInfoBar
took its no-rows branch there while filteredRows < totalRows, so every View()
briefly rendered -- and, the info bar being aria-live, announced -- "Showing 0
to 0 of 0 entries (filtered from N total entries)". Refresh the info bar only
once a block has landed; the paired render was already a no-op at that point.

The mode switch also changes clientWidth by the native vertical bar's width,
which is what applyPinnedColumns sizes the horizontal overscroll padding from,
so the rightmost column stopped landing flush at maximum horizontal scroll
until an unrelated resize recomputed it. Recompute it here with the rest.

On the test side, assert the info bar's range immediately after the flip,
computed from the measured client box rather than hardcoded, and flip back to
overlay mode at the end: the scroll range returning to its original value is
what proves the pre-flip baseline the tail delta is measured against carried
the tail in the first place.
…elpers

filteredRows > 0 was broader than the bootstrap case it was meant to exclude:
a live switch while a filter matches no rows also skipped the refresh, and the
info bar's text is not row-independent there -- it still carries the visible
column range, which is derived from clientWidth and does change at the switch.
bootstrapping is set for exactly the initGrid call and clear for every
setOption one, so guard on that instead.

The two bottom-edge tests had drifted into ~40 duplicated lines: the overflow
precondition, the wheel-to-bottom-and-wait sequence and the last-row geometry
read are now shared helpers.

Also pin the pinned-padding half of the previous commit: the padding is
clientWidth minus the last unpinned column's width, so across the switch it
moves by exactly the client-width delta, which is deterministic in both
scrollbar modes. And derive both ends of the asserted info-bar range from the
live scrollTop -- the viewer restores a saved scroll offset for a frame of the
same name and row count, so a retry can reopen the grid at the bottom and
"Showing 1 to N" would not hold.
…urrent

The mode switch changes clientWidth, which is what computeColumnWindow
derives the rendered column window from, so run syncColumnWindow ahead of the
rebuild the way onResize does. BUFFER_COLS absorbs a scrollbar's width in
practice, but the two "the client box changed" paths should not diverge.
applyPinnedColumns stays alongside it: syncColumnWindow only reaches it when
the window actually moved, which a scrollbar's width usually will not do.

!bootstrapping alone dropped a refresh the previous guard was providing. In
data-import preview mode initWithData publishes a range before
autoSizeColumns and applyPinnedColumns settle the widths that decide whether
the grid overflows horizontally, and there is no fetch response afterwards to
correct it -- so the range could stay a row off. filteredRows is already set
there, so keeping both conditions covers it while still suppressing the
server bootstrap's "Showing 0 to 0 of 0" announcement.

Also assert the overlay test's bottom edge two-sided, so a tail larger than
the bar's height fails as well; the last row's position is measured against
the viewport's own client box, leaving the bar's rect for the one-sided
"clears the bar" check.
@kevinushey
kevinushey merged commit 79d2025 into main Aug 27, 2026
1 of 2 checks passed
@kevinushey
kevinushey deleted the bugfix/18620-data-viewer-last-row-under-scrollbar branch August 27, 2026 23:10

This branch was previously deployed

1 inactive deployment
e2e-playwright — 5ae273b7 Deployed Aug 27, 2026 by kevinushey via windows / e2e-desktop-windows (2) #728
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.

2 participants