feat(Modal): add nesting behaviors and fix third-party overlay dismissal#1896
Draft
stephenjwatkins wants to merge 7 commits into
Draft
feat(Modal): add nesting behaviors and fix third-party overlay dismissal#1896stephenjwatkins wants to merge 7 commits into
stephenjwatkins wants to merge 7 commits into
Conversation
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.
📝 Changes
Adds control over how nested modals stack, and fixes a dismissal bug for modals that host third-party overlays.
Nesting behaviors (feature). New optional
childNestingBehaviorandselfNestingBehaviorprops onModal.TriggerandModalContainercontrol how a modal stacks relative to the modal it's nested under. A connection resolves to one of:stack(default) — both modals keep their own backdrops; matches today's behavior, so existing modals are unchanged.stack-shared-backdrop— the nested modal suppresses its backdrop so only the lowest backdrop shows.replace— the nested modal hides the modal beneath it so only the topmost is visible.Configure from either end:
childNestingBehavioris set on the parent and cascades down the tree;selfNestingBehavioris set on the child, is local (does not cascade), and overrides the parent'schildNestingBehaviorfor that one connection — useful for surgically adjusting a single nested modal without touching its parent.Third-party overlay dismissal (fix). Previously the modal box was tagged
data-react-aria-top-layer, which made react-aria treat every click inside the modal as "not outside," so nested react-aria overlays (e.g.Select,Menu) wouldn't close on outside click. The box now usesdata-live-announcerinstead, whichariaHideOutsidehonors to keep the box visible under a surrounding modal without breaking outside-click dismissal. A new globalshouldCloseOnInteractOutsidealso ensures clicking a nested modal never dismisses the one beneath it, while backdrop clicks and genuine third-party overlays (e.g. Stripe) still behave correctly.Notes for reviewers
No breaking changes. The new props are optional and default to today's behavior. Removed context fields (
hasOpenNestedModal/setHasOpenNestedModal) were internal-only and unused onmain.New nesting logic is isolated in a dedicated
useModalNestinghook; the only shared-path change (shouldCloseOnInteractOutside) is behavior-preserving for existing single modals (verified: clicking aSelectoption or the modal body does not dismiss a standard modal; backdrop dismissal is unchanged).Try the Modal → Nested story; the
childNestingBehaviorcontrol switches between all three modes live.✅ Checklist
Easy UI has certain UX standards that must be met. In general, non-trivial changes should meet the following criteria: