Skip to content

feat(Layout): add defaultHasDividers context for container-controlled dividers - #969

Merged
cixzhang merged 3 commits into
mainfrom
navi/feat/container-default-dividers
Mar 30, 2026
Merged

feat(Layout): add defaultHasDividers context for container-controlled dividers#969
cixzhang merged 3 commits into
mainfrom
navi/feat/container-default-dividers

Conversation

@cixzhang

@cixzhang cixzhang commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Containers like XDSDialog can now control whether their layout headers/footers show dividers by default, without each header/footer having to hardcode it.

How it works

XDSLayout accepts a new defaultHasDividers prop. When set, it provides the value via XDSLayoutDividerContext. XDSLayoutHeader and XDSLayoutFooter read from this context when hasDivider is not explicitly passed.

Resolution order: explicit hasDivider prop → context defaultHasDividersfalse

Changes

  • New: XDSLayoutDividerContext — React context for default divider state
  • XDSLayout — accepts defaultHasDividers?: boolean, provides via context
  • XDSLayoutHeader / XDSLayoutFooter — read context when hasDivider is undefined
  • XDSDialogHeader — no longer hardcodes hasDivider=true; inherits from layout context
  • Dialog stories — removed explicit hasDivider from footers (now context-driven)
  • Tests — 4 new tests covering context resolution, explicit overrides

API Convention

Follows default + has prefix pattern per API Conventions wiki: defaultHasDividers (like defaultHasSelection, defaultIsOpen).

Ref #840


@cixzhang
cixzhang requested a review from josephfarina as a code owner March 30, 2026 01:35
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 30, 2026
@github-actions

github-actions Bot commented Mar 30, 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.

Modified Components

Dialog · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 752B N/A
Lines of Code N/A 358 -
Complexity N/A Very High (46) -
Layout · View in Storybook · 🆕 XDSLayoutDividerContext
Metric Before After Delta
Bundle Size (ESM) N/A 1.1KB N/A
Lines of Code N/A 1009 -
Complexity N/A Very High (70) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 11.4KB 18.1KB 2.8KB

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

XDSLayout - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 4/10 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

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

… dividers

Containers like XDSDialog can now control whether their layout headers/footers
show dividers by default, without each header/footer having to hardcode it.

- XDSLayout accepts new `defaultHasDividers` prop, provided via context
- XDSLayoutHeader/Footer read context when `hasDivider` is not explicitly set
- Explicit `hasDivider` on header/footer always overrides the context
- XDSDialogHeader no longer hardcodes hasDivider=true — inherits from layout
- Dialog stories updated to use the context-driven default (no dividers)
@cixzhang
cixzhang force-pushed the navi/feat/container-default-dividers branch from 526cdb8 to af35e57 Compare March 30, 2026 02:00
cixzhang and others added 2 commits March 30, 2026 04:52
…a CSS sibling selectors

Instead of header/footer using negative margins to collapse spacing,
content now collapses its own padding using stylex.when.ancestor(:has())
selectors that detect whether adjacent header/footer has a divider.

This fixes scrollable layouts (e.g. dialogs without dividers) where
content would scroll flush against header/footer text with no breathing room.

Changes:
- Header/Footer: add data-divider attribute when divider is active,
  remove collapseBottom/collapseTop negative margin styles
- Content: use ancestor :has() selectors to zero out padding-block-start/end
  when adjacent header/footer lacks data-divider

Co-authored-by: Navi <navi@navibot.dev>
…ectors

The stylex.when.ancestor() API requires a marker class on the ancestor element.
Without stylex.defaultMarker() on layoutInner, the generated CSS selectors
(.x-default-marker:has(...)) had nothing to match against.

Co-authored-by: Navi <navi@navibot.dev>
@cixzhang
cixzhang merged commit 484d94a into main Mar 30, 2026
14 checks passed
@cixzhang
cixzhang deleted the navi/feat/container-default-dividers branch April 9, 2026 14:31
cixzhang added a commit that referenced this pull request Apr 26, 2026
cixzhang added a commit that referenced this pull request Jun 21, 2026
cixzhang added a commit that referenced this pull request Jun 21, 2026
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