-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Modal won't close on location change in single-page apps. #13930
Comments
Bootstrap doesn't impose or presume any form of client-side routing, so I think we'd be unlikely to do anything here. It should be fairly simple to add a hook into your router that detects and removes/closes the active modal (if any) before navigating to a different route. |
Well, anyway modal should block underlying page from any behavior, doesn't it? |
We attempt to prevent the user from interacting with elements "underneath" the modal, if that's what you mean. |
Yes, that's why I assume, modal should be closed when route is changed. Otherwise it looks pretty strange, when page(route) is changed, but modal is still visible. Another question is how can I close modal from my routing code, that doesn't have reference to modal instance (I'm using AngularJS). |
If you're using Angular, I'd recommend https://github.com/angular-ui/bootstrap |
|
Thank you, cvrebert, I will try that. |
@fat Could you give a ruling on whether we want to do anything here? |
we don't want to do anything here |
that should be left to the user to close as you suggested 👍 |
Well, I think it is a bit difficult to find a way how to close dialog using Angular's wrapper. But probably it's possible, without awkward (in terms of Angular) solution: $('.modal.in').modal('hide') But I think it definitely should close by browser's 'back' button (which doesn't close modal at least in single-page apps) |
I highly recommend you try Angular UI Bootstrap then. |
I use it already. It doesn't provide modal close on 'back' button. Angular's component is just a wrapper around bootstrap's modals, so it has absolutely the same behavior and issues. |
Try filing a feature request with the Angular UI folks perhaps? |
Use setTimeout function to close the modal and redirect to the location
|
For anyone using AngularJS integration I've posted an SO answer describing on how to close all opened modals on route change here: http://stackoverflow.com/a/23766070 |
Steps to reproduce:
Actual result:
Page is rendered with desired location, modal is still open.
Expected result:
Modal is dismissed, page is rendered with desired location
In example above we can see the same page, but with one-page app frameworks, like AngularJS, these location change could lead to complete page rerender.
Real-life use case is when user tries to perform some action inside modal without appropriate rights, it should be redirected to login page, but in that case, modal stays open.
The text was updated successfully, but these errors were encountered: