-
Notifications
You must be signed in to change notification settings - Fork 10
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
Back button #4
Comments
Not the best way to use modals and this question is more related to StackOverflow 🙂 For a native solution, you can use window.addEventListener('beforeunload', (event) => {
event.preventDefault();
event.returnValue = '';
// close your modal
modal.close();
}); OR If you are using ⭐️ The main idea is to catch this event, cancel it, and at that moment close the modal window using |
@Quernest maybe we can add wrapper function for showModal function in the useModal hook. This wrapper will track modal ids which were created in some component. And in useModal hook we will use useEffect to find out when component which created some modals is destroyed. And when it is destroyed we can use destroyModal to close modals created by this component? Because if we do not close modals manually when browser back button it is pressed and some component which created modals is destroyed we can have different issues. |
Great idea, I'll do it soon, thanks! |
How can I close dialog on back button pressed? and prevent back action in navigator?
The text was updated successfully, but these errors were encountered: