Fix and refactor UnderlineNav to resolve CLS issues and improve performance/code quality#7622
Merged
iansan5653 merged 2 commits intounderline-nav-full-css-spikefrom Mar 4, 2026
Merged
Conversation
13 tasks
🦋 Changeset detectedLatest commit: 984b15d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: iansan5653 <2294248+iansan5653@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix and refactor UnderlineNav for performance and CLS issues
Fix and refactor Mar 4, 2026
UnderlineNav to resolve CLS issues and improve performance/code quality
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.
UnderlineNavcaused CLS by measuring item widths in JS after hydration to determine overflow. This replaces that approach with CSS-based overflow detection, eliminating layout shift and removing substantial complexity.How overflow works now:
overflow: hidden— visually disappear without JSscroll-statecontainer queries (pure CSS)IntersectionObservervia context to self-report when overflowed; parent renders those items in the overflow menuWhat changed:
scroll-statecontainer queriesActionMenu(fixes positioning, removes ~100 LOC)React.ChildrenAPI → descendant registry via contextBreaking behavioral changes:
Changelog
New
UnderlineNavitems can now be wrapped in fragments or intermediate components (no longer requires direct children)Changed
UnderlineNavoverflow detection is now CSS-based, eliminating CLSActionMenu; button is right-alignedRemoved
Rollout strategy
Testing & Reviewing
Overflow behavior is best verified by resizing the browser window. The flex layout is easiest to inspect using Chrome DevTools' flex inspector — it clearly shows where wrapped items are hiding.
Merge checklist
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.