-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Drawer] Close persistent drawer on Escape keydown #12188
Comments
@mctep I would suggest you to use a custom modalManager instance, providing it to all the modals you are using (you can use theme for that). Then, you can use the Also, I'm wondering if we should be checking |
@oliviertassinari Thank you for the answer! So I need to wrap all components that use
Sorry, but I do not understand. How does it help with the issue? I do not need to prune the |
Yes, as I was saying it earlier, you can use the theme for that: (
You could be listening for the Escape on your custom drawer component. You could prevent the default event behavior, then the Material-UI's Modal could check if the event default behavior is prevented and skip the close logic. |
Awesome! I didn't know about this API. I'll try it. Thank you.
|
Theme works like a charm! ✨ The best library ever! |
@oliviertassinari, hi, how about for mui v5? Thanks |
Hi!
I want to make right
persistent
drawer (like in three pane interfaces). Also I want to close right pane by Escape pressed. But this keypress works only fortemporary
drawers based onModal
components.Current Behavior
I could add my own
keydown
listener and close my drawer, but I cannot to check that someModal
is opened for properly closing (Escape
closes my drawer and opened modal).I cannot use
temporary
drawer for this because it creates fixeddiv
that fill whole page and blocks other elements on page.Expected Behavior
As the simplest solution I would to suggest to export default
ModalManager
singleton from@material-ui/core/Modal
(Modal.defaultProps.manager
) and add to it some method likehasModals()
.Examples
The text was updated successfully, but these errors were encountered: