Skip to content

Conversation

@pan-kot
Copy link
Member

@pan-kot pan-kot commented Jan 6, 2026

Description

This fixes a table headers trembling when resizing. The issue was reproducible on complex tables and especially those with sticky headers.

Before without sticky header:

Screen.Recording.2026-01-07.at.10.47.42.mov

Before with sticky header:

Screen.Recording.2026-01-07.at.10.48.36.mov

After:

Screen.Recording.2026-01-07.at.10.49.53.mov

Rel: AWSUI-61443

Resolves: #4010

How has this been tested?

  • Existing unit and integration tests, screenshot tests

The fix can be tested manually on any table with resizable columns but especially those with lots of content. It is worth testing it in both React 16 and 18 and also ensure the sticky headers column sync works fine in both resizable and not resizable tables.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.15%. Comparing base (1a5715e) to head (d9cb761).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4159   +/-   ##
=======================================
  Coverage   97.14%   97.15%           
=======================================
  Files         873      874    +1     
  Lines       25642    25655   +13     
  Branches     9284     9283    -1     
=======================================
+ Hits        24910    24924   +14     
+ Misses        726      725    -1     
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 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.

if (!elements) {
return;
}
const resizeColumn = useMemo(
Copy link
Member Author

Choose a reason for hiding this comment

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

This function is called on every pointer move - so throttling helps by ignoring intermediate updates.

Copy link
Member

Choose a reason for hiding this comment

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

[non-blocking] I checked our codebase and notice multiple instance using throttle with useMemo/useCallback. I'd suggest to introduce an abstraction useThrottle for them. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense. I added useThrottleCallback (similar to existing useDebounceCallback).

// Using the tableRef getBoundingClientRect().width instead of the theadRef because in VR
// the tableRef adds extra padding to the table and by default the theadRef will have a width
// without the padding and will make the sticky header width incorrect.
secondaryTableRef.current.style.inlineSize = `${tableRef.current.getBoundingClientRect().width}px`;
Copy link
Member Author

Choose a reason for hiding this comment

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

The table column width utils set widths of both normal and sticky headers at the same time, so there is no need to sync table widths.

Copy link
Member

Choose a reason for hiding this comment

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

The table column width utils set widths of both normal and sticky headers at the same time

Could you point out to the code that does that and why did you change it in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Certainly! Here is where the col widths are synchronised: https://github.com/cloudscape-design/components/blob/main/src/table/use-column-widths.tsx#L141

When researching columns trembling, I realised that the large part of it was due to this line of code (only when sticky header is on). Here we measure the total size of the real table and set it to the sticky table. Due to the async nature of the code, this measurement is not that precise - and often happens before the column widths are settled - and thus contributing to the trembling. I tried to optimise it first, but then realise that this piece of code seems to be no longer relevant, as the same explicit sizes are used for all columns anyways.

@pan-kot pan-kot marked this pull request as ready for review January 7, 2026 10:28
@pan-kot pan-kot requested a review from a team as a code owner January 7, 2026 10:28
@pan-kot pan-kot requested review from NathanZlion and georgylobko and removed request for a team January 7, 2026 10:28
NathanZlion
NathanZlion previously approved these changes Jan 7, 2026
Copy link
Member

@NathanZlion NathanZlion left a comment

Choose a reason for hiding this comment

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

LGTM

@pan-kot pan-kot added this pull request to the merge queue Jan 13, 2026
Merged via the queue into main with commit 90648c6 Jan 13, 2026
119 of 122 checks passed
@pan-kot pan-kot deleted the fix-table-resize-columns-tremble branch January 13, 2026 09:42
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