Skip to content

fix(plugin-chart-table): stop narrowing sticky header/footer width - #43937

Merged
sadpandajoe merged 7 commits into
masterfrom
fix-table-total-cutoff-on-resize
Sep 9, 2026
Merged

sadpandajoe merged 7 commits into
masterfrom
fix-table-total-cutoff-on-resize

Conversation

@sadpandajoe

@sadpandajoe sadpandajoe commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

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's maxWidth. Before this change, the sticky header/footer wrapper's width was computed as maxWidth - <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 same maxWidth-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.tsx was 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 After
Before — Table chart Total row after shrink-then-grow resize After — Table chart Total row after shrink-then-grow resize

Before video: https://gist.githubusercontent.com/sadpandajoe/7f4e908cc05c46e8c03d52213e415a56/raw/5e4158f22b8af532010cf4f1d57c1143d450e28f/before.mp4

Before — Table chart Total row after shrink-then-grow resize recording

After video: https://gist.githubusercontent.com/sadpandajoe/7f4e908cc05c46e8c03d52213e415a56/raw/5e4158f22b8af532010cf4f1d57c1143d450e28f/after.mp4

After — Table chart Total row after shrink-then-grow resize recording

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 confirms master's header/footer width computation subtracts an unvalidated probe value, which is the mechanism this PR removes.

TESTING INSTRUCTIONS

  1. Create a Table Chart on any dataset with a dimension and a SUM(...) metric.
  2. Enable SHOW TOTALS.
  3. On the Customize tab, set the metric's D3 format to Original value (an unformatted, potentially wide number).
  4. Save the chart to a new dashboard.
  5. Edit the dashboard: shrink the chart's height until a vertical scrollbar appears on the table body, then grow it back until all rows are visible again. Save.
  6. Confirm the totals row's value renders in full.

Automated coverage: superset-frontend/plugins/plugin-chart-table/test/DataTable/hooks/useSticky.test.tsx (regression guard for the width calculation) and superset-frontend/plugins/plugin-chart-table/test/DataTable/utils/getScrollBarSize.test.ts.

ADDITIONAL INFORMATION

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
@pull-request-size pull-request-size Bot added size/L and removed size/XL labels Sep 5, 2026
@codecov

codecov Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.83%. Comparing base (1315f5f) to head (d9aef2f).
⚠️ Report is 6 commits behind head on master.

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              
Flag Coverage Δ
javascript 75.38% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…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
@netlify

netlify Bot commented Sep 7, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit d9aef2f
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a9e3b6f0841ca0008bfe286
😎 Deploy Preview https://deploy-preview-43937--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@sadpandajoe
sadpandajoe marked this pull request as ready for review September 7, 2026 04:39
@bito-code-review

bito-code-review Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #91637a

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: dd6a909..d9aef2f
    • superset-frontend/plugins/plugin-chart-table/src/DataTable/hooks/useSticky.tsx
    • superset-frontend/plugins/plugin-chart-table/test/DataTable/hooks/useSticky.test.tsx
    • superset-frontend/plugins/plugin-chart-table/test/DataTable/utils/getScrollBarSize.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas rusackas 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, 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.

@sadpandajoe
sadpandajoe merged commit f66843e into master Sep 9, 2026
136 checks passed
@sadpandajoe
sadpandajoe deleted the fix-table-total-cutoff-on-resize branch September 9, 2026 16:47
hamon-a added a commit to MGDIS/superset that referenced this pull request Sep 14, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Total on Table Chart gets cut off on the Dashboard if the Chart is re-sized

2 participants