-
Notifications
You must be signed in to change notification settings - Fork 811
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
onRequestClose closes all modals when using them recursively. #583
Comments
Cloned the codesandbox with old react 15 and react-modal 2.X and it works as expected. Same as escape button the rest of events doesn't bubble to the parent component. |
@Ne3l I think this is the correct behavior on |
It should cause no warm to include a check like |
The option of moving the modal to be sibling is not plausible on real world usage. In my case inside the modal i render something like this.
About the other solutions you mean the user of the library handles the stopPropagation or the library stops the propagation on requestClose ? Also i'm not sure if i explained properly but clicking on the ModalOverlay does close it properly. The problem comes when you press esc key inside second modal. |
gee, sorry. I probably read on a rush. :) |
Just in case, here is an example of how you can archive the same result using siblings https://github.com/reactjs/react-modal/blob/master/examples/basic/multiple_modals/index.js. |
This is now required when nesting modals (the event will trigger both handleKeyDown). closes reactjs#583.
About the siblings, my example was a simplification there are more components in the app hierarchy. About a prop for blocking event propagation to reach parent, do you think is a good idea to add that to react-modal or should the responsability of catching event propagation be handled by the parents? |
[1] That's fine. I wrote a test for your case, than I realize what was the issue (we had something similar about the click on the overlay). [2] Since this event must be processed on the topmost modal, it should be safe to stop the propagation. |
This is now required when nesting modals (the event will trigger both handleKeyDown). closes reactjs#583.
This is now required when nesting modals (the event will trigger both handleKeyDown). closes reactjs#583.
This is now required when nesting modals (the event will trigger both handleKeyDown). closes reactjs#583.
This is now required when nesting modals (the event will trigger both handleKeyDown). closes reactjs#583.
This is now required when nesting modals (the event will trigger both handleKeyDown). closes #583.
Released |
Rereleased as |
Summary:
When using nested react-modals, closing with escape key closes all modals instead of the last one open.
Steps to reproduce:
Expected behavior:
Only modal 2 is closed and modal 1 stays open.
Link to example of issue:
https://codesandbox.io/s/w70xm5y1y7
additional notes
I suppose this is related to this issue, when bubbling events with Modals it gets to the parent component. This behaviour depending on the situation is quite problematic. I think it didn't happened with old version before react 16 CreatePortal but now it does. Gonna try to create another codesandbox to confirm it.
The text was updated successfully, but these errors were encountered: