Repository navigation
tab: Keep an icon-only tab's width instead of collapsing to the icon - #3792
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Description
An icon-only
Tab(Tab::new().icon(..)) collapses to the width of its icon, so the icons of a segmentedTabBarpack against each other and the selected segment's raised fill hugs the glyph with no inset.The icon branch sizes its content box with
w(inner_height * 1.25), but the same box also carriesflex_1(). That zeroes the flex basis and allows shrinking, so the tab resolves to the icon's own width plus borders: a mediumTabVariant::Tabicon tab measured 18px instead of 37.5px. The fix adds a matchingmin_w, so the box keeps the width it asks for whileflex_1()tabs can still grow to fill the bar (#3032 is unaffected).Regression
This worked until
v0.8.1. Bisecting288767cc..ae6a3fdwith the new test lands on 99576db (Bump v0.8.1), which upgrades GPUI fromgpui-pre 0.3.9to0.3.10and with ittaffyto0.15. The tab code itself did not change there; the newer layout no longer keeps thew(..)width of aflex_1()box when its parent is sized by content, so the explicitmin_wis now needed.Screenshot
Found in an account menu that uses
TabBar::new(..).segmented().small()with three icon tabs (Monitor / Sun / Moon).Impact
Tab::iconchange; labelled tabs,prefix/suffixtabs andFoldertabs go through the other branch and are untouched.inner_height * 1.25content width (e.g. Segmented small 22.5px, medium 30px). ATabBarholding icon tabs becomes correspondingly wider; callers that relied on the collapsed width will see the bar grow.Buttons), so no in-repo layout changes.max_widthstill exempts icon-only tabs.How to Test
cargo test -p gpui-component --features test-support --lib tab::— addsicon_only_tabs_keep_their_width, which checks every variant; it fails before the fix (Tab: icon-only tab is 18px, narrower than its 37.5px content) and passes after.Checklist
cargo runfor story tests related to the changes.🤖 Generated with Claude Code