fix(Section): propagate explicit padding to nested sections - #1972
Merged
Conversation
When a parent XDSSection sets padding={N}, nested sections without
explicit padding would fall back to the theme default (spacing-4)
instead of inheriting the parent's padding value. This caused a
mismatch between edge compensation and content inset.
Fix: set --xds-section-padding on the inner container when explicit
padding is provided. Nested sections using useThemeDefault pick up
this value through CSS custom property cascade.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
cixzhang
enabled auto-merge (squash)
May 2, 2026 21:36
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
When a parent XDSSection sets padding={N}, nested sections without
explicit padding would fall back to the theme default (spacing-4)
instead of inheriting the parent's padding value. This caused a
mismatch between edge compensation and content inset.
Fix: set --xds-section-padding on the inner container when explicit
padding is provided. Nested sections using useThemeDefault pick up
this value through CSS custom property cascade.
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
When a parent XDSSection sets padding={N}, nested sections without
explicit padding would fall back to the theme default (spacing-4)
instead of inheriting the parent's padding value. This caused a
mismatch between edge compensation and content inset.
Fix: set --xds-section-padding on the inner container when explicit
padding is provided. Nested sections using useThemeDefault pick up
this value through CSS custom property cascade.
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.
Problem
When nesting
<XDSSection>inside a parent with explicit padding, the inner section falls back to the theme default (--spacing-4/ 16px) instead of inheriting the parent's padding:The inner section's edge compensation uses the parent's 24px padding (correct negative margins), but its own content padding is 16px — causing a visual mismatch.
Fix
When a section sets explicit
padding, propagate the value via--xds-section-paddingCSS custom property on the inner container. Nested sections usinguseThemeDefault: 'section'already read from this property in the var() fallback chain, so they naturally inherit the parent's value through CSS cascade.The propagation uses
spacingVars(not hardcoded px) so it respects custom theme spacing scales.Changes
padding.stylex.ts— AddedsectionPaddingPropagationStylesmap (SpacingStep → --xds-section-padding)XDSSection.tsx— Apply propagation style whenpaddingis explicitly setSection.stories.tsx— AddedNestedPaddingInheritancestory showing correct behaviorXDSSection.test.tsx— Added tests for nested section rendering