Repository navigation
fix(plugin-chart-table): stop narrowing sticky header/footer width - #43937
Conversation
The sticky header/footer wrapper width was narrowed by a separately JS-measured scrollbar size, while the column widths shared via colgroup were computed against the browser's own `scrollbar-gutter: stable` reservation used by the body div. These two numbers aren't guaranteed to agree, and when the probe overstates the real reservation the fixed-layout table overflows its `overflow: hidden` wrapper, clipping the rightmost column -- typically the totals row once a chart is resized enough to need a vertical scrollbar. Header and footer now reserve space via the same `scrollbar-gutter` property the body already uses, so all three always agree. Fixes #21063
scrollbar-gutter: stable's reserved width depends on whether custom ::-webkit-scrollbar styling is applied to that element (verified in both headless and headed Chromium: 15px unstyled vs 8px styled, matching CUSTOM_SCROLLBAR_SIZE). The previous fix reserved the gutter on the header/footer wrappers without also giving them the same custom scrollbar CSS the body/sizer carry, so they reserved a different (larger) amount and could still clip the shared colgroup's rightmost column. Also corrects the RCA: real, non-headless browser testing shows unmodified master's original scrollBarSize-based computation does not diverge from the body/sizer's reservation under any real condition reproduced in this investigation (only headless Chromium's synthetic scrollbar probe showed a difference, which turned out to be a headless-only rendering artifact, not representative of a real user's browser). The fix still removes a real, demonstrated defect class -- relying on two independently-measured scrollbar-space numbers to agree -- rather than the exact historical trigger, which remains unpinned.
…ng, pin scrollBarStyles regression The previous round's RCA claimed clipping based on comparing clientWidth to scrollWidth on an overflow:hidden element, but scrollbar-gutter's reserved space is phantom for overflow:hidden (never rendered as a real scrollbar), so it doesn't move the actual clip boundary. Real-browser hit-testing (document.elementFromPoint sweeps in headed Chromium) shows that comparison doesn't demonstrate clipping. Retract that claim in RCA.md and replace it with the structural reason the fix is correct regardless of any browser's scrollbar-probe accuracy: the shared colgroup is always bounded by the sizer's clientWidth, which is always bounded by maxWidth, so an unconditional width: maxWidth on header/footer can never be narrower than the table it must display. Also add a /** @jsxImportSource @emotion/react */ pragma to useSticky.tsx so its css prop is observable in this repo's Jest/Babel setup the same way webpack/SWC already observes it in production, and use that to extend the regression test to assert header/footer actually receive the scrollBarStyles-generated class (previously only the inline width/ scrollbarGutter half was pinned, so the test passed with or without the scrollBarStyles addition). Refs #21063
…e any casts in sticky test Some comments (useSticky.tsx, useSticky.test.tsx, RCA.md) still framed the scrollbar-gutter/scrollBarStyles matching as the mechanism that prevents the reported clipping, contradicting this branch's own hit-testing conclusion that it's the unconditional width: maxWidth change that's load-bearing, with gutter/style matching kept only as an unverified, secondary consistency measure for combined horizontal+vertical scrolling. Rewrite those comments and RCA sections to say so explicitly, and fix a getScrollBarSize.test.ts comment that still described the removed maxWidth - scrollBarSize subtraction as the header's "shrink amount". Also remove the `as any` casts from the sticky regression test: type `columns` as `Column<Row>[]` and pass `useSticky` directly, letting `headerGroups`/`rows`/`cells` infer their existing react-table types (already declared in `src/DataTable/types/react-table.d.ts`) instead of bypassing type-checking of the exercised contract. Refs #21063
…ky test comment The MOCKED_SCROLLBAR_PROBE_SIZE comment still described the mock as distinguishing the JS probe from the CSS gutter reservation, the same probe-vs-gutter framing already retracted and corrected everywhere else in this file and RCA.md. Reword it to match: the mock detects reintroduction of the removed maxWidth - scrollBarSize subtraction, not a gutter/probe mismatch. Refs #21063
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #43937 +/- ##
==========================================
+ Coverage 79.81% 79.83% +0.01%
==========================================
Files 2913 2913
Lines 170313 170312 -1
Branches 39480 39479 -1
==========================================
+ Hits 135932 135962 +30
+ Misses 31859 31828 -31
Partials 2522 2522
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…test comments RCA.md was removed from the repo (internal process artifact, not meant to ship publicly), but two comments in useSticky.test.tsx still pointed to it with "see RCA.md". Drop those dangling parentheticals; the surrounding comment text already carries the substantive explanation on its own. Refs #21063
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #91637aActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
rusackas
left a comment
There was a problem hiding this comment.
LGTM, approving! The sizer div's measurements are already constrained by maxWidth, so matching header/footer to body width unconditionally can't clip anything. Real structural fix, not a tuned constant.
Port of apache#43937 (f66843e), adapted to 5.0-mgdis. The header/footer wrappers were narrowed to `maxWidth - scrollBarSize`, which clips the shared fixed-layout colgroup whenever the JS-measured scrollbar width disagrees with the space the body actually reserves (browser, platform and zoom dependent). They now always keep the full `maxWidth` -- the colgroup is bounded by the sizer's clientWidth, itself bounded by `maxWidth`, so it can never overflow them -- and carry `scrollbar-gutter: stable` like the body, so their reported clientWidth stays consistent with the body's for the synced horizontal `scrollLeft`. Upstream's `getCustomScrollBarSize()` (apache#42573) is deliberately not ported: it only makes sense alongside the custom 8px `::-webkit-scrollbar` styling introduced by apache#35338, which 5.0 doesn't have -- the table body here renders a native scrollbar, so measuring an 8px probe would re-introduce a ~7px misalignment on Chrome/Edge. PLAID-147319 Co-Authored with Claude Code
SUMMARY
The Table chart's sticky header/footer wrapper subtracted a JS-probed scrollbar-size estimate from its width (
maxWidth - getCustomScrollBarSize()). That estimate doesn't always match the browser's actual scrollbar/gutter reservation used by the scrollable body, so the header/footer could end up narrower than the shared column widths actually need. When that happened, the rightmost column's content -- including a totals row -- could render outside the wrapper's visible area after a resize that toggles the vertical scrollbar on and off.This removes the subtraction: the header and footer now always use the full available width (the same width the shared column group is already sized against), and they also get the same scrollbar-gutter/scrollbar-styling treatment as the body, so all three stay visually consistent during horizontal scrolling.
ROOT CAUSE
The shared
<colgroup>column widths are measured from a hidden "sizer" element whose width is bounded by the chart'smaxWidth. Before this change, the sticky header/footer wrapper's width was computed asmaxWidth - <a separately JS-measured scrollbar-size estimate>, which is not guaranteed to match what the sizer/body actually reserve for their real scrollbar in every browser -- when the estimate overstated the real reservation, the wrapper ended up narrower than the columns it had to display, and the rightmost column (here, the totals row) rendered outside it.The fix removes that subtraction. Header/footer wrapper width is now always the full
maxWidth, which by construction can never be narrower than what the shared<colgroup>needs (the colgroup's own widths are bounded by that samemaxWidth-constrained sizer). This holds regardless of any browser's specific scrollbar width, so it closes the general class of risk rather than tuning the previous estimate.Separately, this file's header/footer/body column-width-sync mechanism has been touched by several independent fixes over the years (#21064, #26964, #36891, #42573) as different trigger conditions surfaced -- there was no regression test pinning either invariant this fix relies on, so
plugins/plugin-chart-table/test/DataTable/hooks/useSticky.test.tsxwas added to cover both: header/footer's width always matching body's, and header/footer's scrollbar-gutter/styling always matching body's.Two related-but-separate issues were found and intentionally left out of scope for this fix (noted here for anyone touching this file next): (1)
needScrollBar's height comparison in the same hook double-counts header/footer height against the body-only budget, making the vertical scrollbar state flip on earlier and off later than necessary; (2) when a chart is narrower than a total's own unbreakable content width, the total still clips regardless of scrollbar state -- a "chart too narrow for this content" case distinct from the scrollbar-driven bug fixed here.BEFORE/AFTER SCREENSHOTS
Before video: https://gist.githubusercontent.com/sadpandajoe/7f4e908cc05c46e8c03d52213e415a56/raw/5e4158f22b8af532010cf4f1d57c1143d450e28f/before.mp4
After video: https://gist.githubusercontent.com/sadpandajoe/7f4e908cc05c46e8c03d52213e415a56/raw/5e4158f22b8af532010cf4f1d57c1143d450e28f/after.mp4
Note: on this QA sandbox's Chromium build, the "before" (unmodified
master) capture did not visually reproduce the reported cut-off — the build's scrollbar-size probe measured less than the real scrollbar-gutter reservation, the opposite of the direction needed to trigger the clip, a real browser/OS-dependent reproducibility limit rather than a flaw in the repro steps. The code diff independently confirmsmaster's header/footer width computation subtracts an unvalidated probe value, which is the mechanism this PR removes.TESTING INSTRUCTIONS
SUM(...)metric.Automated coverage:
superset-frontend/plugins/plugin-chart-table/test/DataTable/hooks/useSticky.test.tsx(regression guard for the width calculation) andsuperset-frontend/plugins/plugin-chart-table/test/DataTable/utils/getScrollBarSize.test.ts.ADDITIONAL INFORMATION