Skip to content

Conversation

@Huiet
Copy link

@Huiet Huiet commented Nov 25, 2025

…al manager.

Adding a property (shouldReplaceExistingMOdal) to be used by modal manager that allow modals to be opened without closing other modals that may be opened. This works in a way similar to nesting modals in the DOM, but can be done programatically.

The underlying change was to change the current modal in the modal manager to be an array, that way multiple modals can be rendered at a time instead of just one.

Huiet and others added 5 commits November 25, 2025 09:48
…al manager.

Adding a property (`shouldReplaceExistingMOdal`) to be used by modal manager that allow modals to be opened without closing other modals that may be opened. This works in a way similar to nesting modals in the DOM, but can be done programatically.

The underlying change was to change the `current` modal in the modal manager to be an array, that way multiple modals can be rendered at a time instead of just one.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for stacking multiple modals simultaneously in the Mantine modals manager by introducing a shouldReplaceExistingModal prop. By default, opening a new modal replaces the currently opened modal (maintaining backward compatibility), but setting shouldReplaceExistingModal: false allows multiple modals to be stacked on top of each other.

Key changes:

  • The current state in the modal reducer changed from a single modal to an array of modals to support multiple visible modals
  • Added shouldReplaceExistingModal property to ModalSettings type
  • Updated modal rendering to iterate over all current modals with incremental z-index values

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/@mantine/modals/src/context.ts Added shouldReplaceExistingModal optional property to ModalSettings type definition
packages/@mantine/modals/src/reducer.ts Changed current from single modal to array; updated OPEN, CLOSE, CLOSE_ALL, and UPDATE actions to handle multiple modals
packages/@mantine/modals/src/ModalsProvider.tsx Refactored modal rendering to map over state.current array with incremental z-index; extracted modal content logic into getModalContent callback
packages/@mantine/modals/src/use-modals/use-modals.test.tsx Added comprehensive test suite covering backward compatibility, multiple modal stacking for all modal types, and mixed modal type scenarios
packages/@mantine/modals/src/Modals.story.tsx Added interactive story demonstrating multiple stacked modals and mixed modal types
packages/@docs/demos/src/demos/modals/Modals.demo.multiple.tsx Created new demo showcasing the multiple modals feature with code example
packages/@docs/demos/src/demos/modals/index.ts Exported the new multiple demo
apps/mantine.dev/src/pages/x/modals.mdx Added documentation section explaining the new feature with demo reference

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rtivital
Copy link
Member

rtivital commented Dec 8, 2025

It works incorrectly with escape key. When multiple modals are opened and escape key is pressed, the first one that closes is the underlying modal. See example of incorrect behavior on the video.

Screen.Recording.2025-12-08.at.22.50.08.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants