-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: prevent CSS variable bleeding in nested tabs #4348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prevent CSS variable bleeding in nested tabs #4348
Conversation
Fixes saadeghi#4200 CSS custom properties like --tab-p and --tab-radius-min were inheriting from parent .tabs elements to nested .tabs elements, causing style bleeding. This fix resets all inheritable CSS variables in the base .tabs class, ensuring nested tabs get their own default values instead of inheriting from parent tabs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes issue #4200 where nested .tabs components inherit CSS custom properties from their parent tabs, causing style bleeding. The solution adds CSS variable resets in the base .tabs class to ensure each tabs component starts with default values rather than inheriting from parent elements.
Key changes:
- Reset inheritable CSS variables (
--tabs-height,--tabs-direction,--tab-height,--tab-p,--tab-radius-min) in the.tabsclass - Include incidental formatting changes to gradient and border-radius declarations
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| --tab-p: 0.75rem; | ||
| --tab-radius-min: calc(0.75rem - var(--border)); |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These CSS variable declarations duplicate the same values already defined in the .tab class (lines 18 and 26). While resetting these variables in .tabs is necessary to prevent inheritance from parent .tabs elements, consider whether these specific variables need to be reset here given that:
- The size modifiers (
.tabs-xs,.tabs-lg, etc.) set--tab-pand--tab-radius-minon the.tabelement using the child selector& > .tab, not on.tabsitself - Only
--tab-heightis actually set directly on.tabsby the size modifiers
If the goal is to prevent nested .tab elements from inheriting from parent .tab elements, these resets in .tabs may not achieve that since CSS variables inherit through the DOM tree regardless of selector specificity. The .tab class already defines these variables, so nested .tab elements would use those values, not values from a parent .tabs.
| --tab-p: 0.75rem; | |
| --tab-radius-min: calc(0.75rem - var(--border)); |
| #0000 calc(69% - var(--border)), var(--tab-border-color) calc(69% - var(--border) + 0.25px), | ||
| var(--tab-border-color) 69%, var(--tab-bg) calc(69% + 0.25px); |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This formatting change appears to be unrelated to the nested tabs fix. The multi-line gradient definition has been reformatted to use fewer lines. While this doesn't break functionality, it's generally better to keep formatting changes separate from bug fixes in different commits or PRs for easier code review and git history tracking.
| #0000 calc(69% - var(--border)), var(--tab-border-color) calc(69% - var(--border) + 0.25px), | |
| var(--tab-border-color) 69%, var(--tab-bg) calc(69% + 0.25px); | |
| #0000 calc(69% - var(--border)), | |
| var(--tab-border-color) calc(69% - var(--border) + 0.25px), | |
| var(--tab-border-color) 69%, | |
| var(--tab-bg) calc(69% + 0.25px); |
| min(var(--tab-height) / 2, var(--radius-field)) + min(0.25rem, var(--tabs-box-radius)) - | ||
| var(--border) |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to lines 29-30, this formatting change appears to be unrelated to the nested tabs fix. Consider keeping formatting changes separate from bug fixes for better code review and git history tracking.
|
So mainly Copilot changes something and then comments that the change should not be applied because it does nothing? :) The original problem was already fixed - the draft PR is kept open because it has some interesting further development ideas, but I have no bandwidth for the moment to implement them. |
|
@pdanpdan The copilot was actually doing review. But You're absolutely right, and I apologize for the confusion! After reviewing the git history, I can see that commit My changes added Closing this PR as the original issue was already resolved. Thanks for pointing this out! Regarding the "interesting further development ideas" mentioned in PR #4213:
These are more ambitious refactoring goals that go beyond just fixing the style bleeding issue. |
Summary
Fixes #4200 - Nested tabs inherit styles from parent tabs
Problem
When nesting
.tabscomponents inside each other, CSS custom properties like--tab-pand--tab-radius-minwere inheriting from parent.tabselements to nested.tabselements. This caused style bleeding where nested tabs would incorrectly inherit sizing and styling from their parent tabs.For example, if a parent tab was
.tabs-lg, the nested tabs would also become large because they inherited the--tab-heightvalue from the parent.Solution
Reset all inheritable CSS variables in the base
.tabsclass so that each.tabselement starts with its own default values instead of potentially inheriting from a parent.tabs:Testing
Related