Skip to content

fix(plugin-chart-table): align sticky header column dividers with table body - #42573

Merged
sadpandajoe merged 4 commits into
apache:masterfrom
preset-io:table-header-divider-alignment
Aug 6, 2026
Merged

sadpandajoe merged 4 commits into
apache:masterfrom
preset-io:table-header-divider-alignment

Conversation

@sadpandajoe

Copy link
Copy Markdown
Member

SUMMARY

In the Table chart, the sticky column-header divider lines can be horizontally offset from the table body's column dividers (worst at the right-most column), making the grid look misaligned whenever the body has a vertical scrollbar.

Root cause: the sticky header and the scrollable body are rendered as two separate <table> elements. To keep their columns aligned, useSticky shrinks the header container by getScrollBarSize() when the body scrolls vertically. The body's scrollable area uses a custom thin scrollbar (::-webkit-scrollbar { width: 8px }), but getScrollBarSize() measured a hidden probe element with no custom scrollbar styling — so on Chrome/Edge it returned the native scrollbar width (~15px) instead of the 8px that actually renders. The header was therefore shrunk by ~15px while the body's real scrollbar only consumes 8px, throwing every column divider ~7px out of alignment.

CHANGE

  • Introduce a shared CUSTOM_SCROLLBAR_SIZE constant (exported from getScrollBarSize.ts) and use it for the body's ::-webkit-scrollbar width/height in useSticky.tsx, so the header-shrink amount and the body's rendered scrollbar can't drift apart.
  • In getScrollBarSize(), apply the same ::-webkit-scrollbar rule to the hidden measurement probe (via a scoped <style>, since pseudo-elements can't be set inline) so the measured width matches what actually renders.

TESTING INSTRUCTIONS

  • Create a Table chart tall enough to show a vertical scrollbar in Chrome/Edge; confirm the header column dividers line up with the body column dividers across scroll states (previously ~7px off at the right-most column).
  • Unit tests added in getScrollBarSize.test.ts verify the probe is measured with the shared custom scrollbar size and that the constant stays in sync with the rendered style.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

…asuring the custom scrollbar width

Reported by a customer: on Table chart, the sticky header's column
dividers didn't line up with the body's dividers, worst at the
rightmost column. getScrollBarSize() measured a native ~15px
scrollbar, but the body actually renders an 8px custom webkit
scrollbar, so the header was over-shrunk by ~7px. The measurement
probe now applies the same custom scrollbar styling, and both the
probe and the sticky table's scrollbar CSS pull from a single
CUSTOM_SCROLLBAR_SIZE constant so they can't drift apart again.
@bito-code-review

bito-code-review Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Bito Review Skipped - Source Branch Not Found

Bito didn’t review this change because the pull request is no longer valid. It may have been merged, or the source/target branch may no longer exist.

@dosubot dosubot Bot added browser:chrome Related to the Chrome browser change:frontend Requires changing the frontend viz:charts:table Related to the Table chart labels Jul 29, 2026
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. The getScrollBarSize utility now forces a measurement based on the 8px custom scrollbar width, which is then used by TableChart.tsx for container compensation. If the outer container does not use the same custom scrollbar, it will have a different native scrollbar width, leading to the reported layout drift.

To resolve this, you should separate the concerns: keep a utility that measures the actual native scrollbar width (without forcing custom styles) for general use, and use a constant for the custom scrollbar width where specifically needed (e.g., in StickyWrap).

Proposed Fix

  1. Revert getScrollBarSize.ts to measure the native scrollbar width without injecting the custom style probe.
  2. Continue using CUSTOM_SCROLLBAR_SIZE constant in StickyWrap for styling.

Would you like me to implement these changes? I can also check the rest of the PR comments if you would like to address them as well.

@codecov

codecov Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 65.58%. Comparing base (50c84f2) to head (58a89eb).
⚠️ Report is 54 commits behind head on master.

Files with missing lines Patch % Lines
...hart-table/src/DataTable/utils/getScrollBarSize.ts 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42573      +/-   ##
==========================================
- Coverage   65.59%   65.58%   -0.01%     
==========================================
  Files        2819     2819              
  Lines      160372   160388      +16     
  Branches    36617    36622       +5     
==========================================
+ Hits       105188   105197       +9     
- Misses      53120    53127       +7     
  Partials     2064     2064              
Flag Coverage Δ
javascript 71.75% <96.00%> (-0.01%) ⬇️

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.

@sadpandajoe sadpandajoe added the 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR label Jul 30, 2026
@sadpandajoe
sadpandajoe requested review from msyavuz and rusackas July 30, 2026 17:13
@github-actions github-actions Bot added 🎪 7d3d9a8 🚦 building 🎪 ⌛ 48h Environment expires after 48 hours (default) and removed 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR labels Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime is building environment on GHA for 7d3d9a8

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

🎪 Showtime deployed environment on GHA for 58a89eb

• Environment: http://54.212.30.151:8080 (admin/admin)
• Lifetime: 48h auto-cleanup
• Updates: New commits create fresh environments automatically

@SBIN2010 SBIN2010 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!
It works perfectly during manual testing! Thanks for the fix.

@sadpandajoe
sadpandajoe merged commit ae66b69 into apache:master Aug 6, 2026
82 checks passed
@sadpandajoe
sadpandajoe deleted the table-header-divider-alignment branch August 6, 2026 22:40
@github-actions github-actions Bot removed 🎪 ⌛ 48h Environment expires after 48 hours (default) 🎪 58a89eb 🌐 54.212.30.151:8080 labels Aug 6, 2026
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

Labels

browser:chrome Related to the Chrome browser change:frontend Requires changing the frontend plugins size/L viz:charts:table Related to the Table chart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants