Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(Dialog,MobileNav): replace :where([open]) with prop-driven open styles (#1652)

Cindy Zhang44c59b7eb851
diff --git a/packages/core/src/Dialog/XDSDialog.tsx b/packages/core/src/Dialog/XDSDialog.tsx
index 5b614ea932..aadb39fe06 100644
--- a/packages/core/src/Dialog/XDSDialog.tsx
+++ b/packages/core/src/Dialog/XDSDialog.tsx
@@ -123,21 +123,11 @@ const styles = stylex.create({
'--_dialog-radius': radiusVars['--radius-container'],
borderRadius: 'var(--_dialog-radius)',
boxShadow: shadowVars['--shadow-high'],
- display: {
- default: 'none',
- ':where([open])': 'flex',
- },
+ display: 'none',
flexDirection: 'column',
height: 'fit-content',
overscrollBehavior: 'contain',
- opacity: {
- default: 0,
- ':where([open])': 1,
- },
- animationName: {
- default: 'none',
- ':where([open])': enterDirectional,
- },
+ opacity: 0,
animationDuration: durationVars['--duration-medium-max'],
animationTimingFunction: easeVars['--ease-standard'],
animationFillMode: 'backwards' as const,
@@ -150,6 +140,14 @@ const styles = stylex.create({
':focus-visible': '2px',
},
},
+ // Applied via isOpen prop — avoids :where([open]) attribute selectors
+ // which have zero specificity and can lose to default styles depending
+ // on CSS source order in the build output.
+ open: {
+ display: 'flex',
+ opacity: 1,
+ animationName: enterDirectional,
+ },
// Backdrop using ::backdrop pseudo-element
backdrop: {
'::backdrop': {
@@ -453,6 +451,7 @@ export function XDSDialog({
xdsClassName('dialog', {variant}),
stylex.props(
styles.dialog,
+ isOpen && styles.open,
styles.backdrop,
styles.isolateEdgeSignals,
!isFullscreen && dynamicStyles.sizing(width, maxHeight),
diff --git a/packages/core/src/MobileNav/XDSMobileNav.tsx b/packages/core/src/MobileNav/XDSMobileNav.tsx
index 43cf626a43..f08fbc08fe 100644
--- a/packages/core/src/MobileNav/XDSMobileNav.tsx
+++ b/packages/core/src/MobileNav/XDSMobileNav.tsx
@@ -62,13 +62,12 @@ const styles = stylex.create({
// Prevent touch gestures (pull-to-refresh, background scroll) passing through
touchAction: 'none',
outline: 'none',
- // Native <dialog> uses display:none when closed — we preserve that
- // by only setting display when [open] via :where() selector.
- // This prevents the dialog from blocking pointer events when closed.
- display: {
- default: 'none',
- ':where([open])': 'flex',
- },
+ // Native <dialog> uses display:none when closed.
+ // Open state applied via isOpen prop to avoid :where([open]) specificity issues.
+ display: 'none',
+ },
+ open: {
+ display: 'flex',
},
// ::backdrop is provided by the browser's top layer
backdrop: {
@@ -399,6 +398,7 @@ export function XDSMobileNav({
xdsClassName('mobile-nav', {side: resolvedSide}),
stylex.props(
styles.dialog,
+ isOpen && styles.open,
styles.backdrop,
isOpen && styles.backdropOpen,
xstyle,