Repository navigation
fix(tabs): re-measure Tabs.List overflow with ResizeObserver - #708
Merged
Merged
Conversation
Tabs.List only re-measured its overflow on window resize and on scroll, so it never became scrollable when its container shrank, a sibling appeared or grew, or the tab content itself grew after mount. Replace the window resize listener and the initial rAF measurement with a ResizeObserver on the scrollable element (available width) and the list element (content width). Also return early in updateFade when the list isn't scrollable. Fixes #707 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKGZMiunH84FFWpx6zH4fN
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKGZMiunH84FFWpx6zH4fN
…esize updates - Observe the content element via an explicit contentRef instead of relying on firstElementChild - Call updateFade directly from the ResizeObserver, which already fires once per frame after layout, instead of deferring it another frame - Loop over the story test cases instead of repeating the steps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKGZMiunH84FFWpx6zH4fN
size-limit report 📦
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useFadeSideonly re-measuredclientWidth < scrollWidthon windowresizeand on scroll. SoTabs.Listnever became scrollable when its available width changed for any other reason: the container was resized, a sibling appeared or grew, or the tabs themselves grew (a label changed, a badge appeared, a font loaded).This PR replaces the
windowresize listener and the initialrequestAnimationFramemeasurement with aResizeObserverthat watches:.innerelement, which catches changes to its available width (clientWidth).listelement, which catches changes to the content width (scrollWidth).TabsListpasses it to the hook through a newcontentRefoption.ResizeObserverreports once when observation starts, so it covers the initial measurement too. It already reports once per frame after layout, so it callsupdateFadedirectly. The scroll listener still goes throughrafThrottle.updateFadenow also returns early when the list isn't scrollable.I added a changeset (
reshaped: patch) and atest: overflow on size changestory. It toggles the container width, then a tab label's length, and checks that.innerswitches betweenoverflow: visibleandoverflow: autowith no window resize.Related Issue
Fixes #707
Screenshots / Recordings
No visual changes. The bug is reproduced and covered by the new story.
Notes for Reviewers
expected 'visible' to be 'auto').🤖 Generated with Claude Code
https://claude.ai/code/session_01TKGZMiunH84FFWpx6zH4fN