Skip to content

fix(Section): propagate explicit padding to nested sections - #1972

Merged
cixzhang merged 2 commits into
mainfrom
navi/fix/nested-section-padding
May 2, 2026
Merged

fix(Section): propagate explicit padding to nested sections#1972
cixzhang merged 2 commits into
mainfrom
navi/fix/nested-section-padding

Conversation

@cixzhang

@cixzhang cixzhang commented May 2, 2026

Copy link
Copy Markdown
Contributor

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:

<XDSSection padding={6}>   {/* 24px */}
  <XDSSection>             {/* gets 16px instead of 24px */}
    ...
  </XDSSection>
</XDSSection>

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-padding CSS custom property on the inner container. Nested sections using useThemeDefault: '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 — Added sectionPaddingPropagationStyles map (SpacingStep → --xds-section-padding)
  • XDSSection.tsx — Apply propagation style when padding is explicitly set
  • Section.stories.tsx — Added NestedPaddingInheritance story showing correct behavior
  • XDSSection.test.tsx — Added tests for nested section rendering

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.
@vercel

vercel Bot commented May 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
xds-sandbox Ready Ready Preview, Comment May 2, 2026 9:48pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label May 2, 2026
@cixzhang
cixzhang enabled auto-merge (squash) May 2, 2026 21:36
@github-actions

github-actions Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 17.4KB 27.1KB 4.0KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang
cixzhang merged commit 02b0b8d into main May 2, 2026
20 checks passed
@github-actions
github-actions Bot deleted the navi/fix/nested-section-padding branch May 3, 2026 06:59
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant