Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

closeModal not working with openModal #2436

Closed
Eliasmgprado opened this issue Sep 13, 2022 · 4 comments
Closed

closeModal not working with openModal #2436

Eliasmgprado opened this issue Sep 13, 2022 · 4 comments
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)

Comments

@Eliasmgprado
Copy link
Contributor

What package has an issue

@mantine/modals

Describe the bug

Want to open mutiple modals with openModal() function and close the modals with closeModal() function, using the modalId provided to the openModal() function. However, closeModal() is closing all opened modals, insted of the modal with the provided modalId.

What version of @mantine/hooks page do you have in package.json?

5.3.0

If possible, please include a link to a codesandbox with the reproduced problem

https://codesandbox.io/embed/thirsty-archimedes-bydsjh?fontsize=14&hidenavigation=1&theme=dark

Do you know how to fix the issue

No

Are you willing to participate in fixing this issue and create a pull request with the fix

No

Possible fix

No response

@rtivital
Copy link
Member

Hi @Eliasmgprado, see multiple opened modals example – https://mantine.dev/others/modals/#multiple-opened-modals

@Eliasmgprado
Copy link
Contributor Author

Eliasmgprado commented Sep 14, 2022

The example uses openContextModal instead of openModal, the problem is with openModal function. As showed in the code sandbox, when multiple modal are opened with openModal function, you can`t close a single modal with closeModal() function, providing the modalId passed to the props of openModal(). The closeModal() function close all the opened modals, and not just the one of the provided id.

@rtivital rtivital added the help wanted Contributions from community are welcome label Sep 14, 2022
@UgurKacak
Copy link

Hello,
The top right close button is working as expected. However, closeModal("butonId") method call inside onClick, not working as expected. Because while this call happened, ModalProvider's closeModal function faced an empty state instead of the state that holds two opened modals. I think the problem is here.

rtivital pushed a commit that referenced this issue Sep 16, 2022
@rtivital rtivital added Fixed patch Completed issues that will be published with next patch (1.0.X) and removed help wanted Contributions from community are welcome labels Sep 16, 2022
@rtivital
Copy link
Member

Fixed in 5.3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)
Projects
None yet
Development

No branches or pull requests

3 participants