Modal doesn't hide if hide is called during show animation
See original GitHub issueHi,
because of this lines (modal.js 160-162)
if (this._isTransitioning || !this._isShown) { return; }
if you invoke modal('hide') before it has ended the show animation it won’t hide.
I wasn’t able to understand if this was a design choice or some bug preventing, I tested it removing the return and it hasn’t shown any problem, the modal hides before the animation has ended.
I was updating my application to 4 beta and noticed that most of the modals weren’t closing anymore at the end of a loading.
Regards
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Twitter bootstrap modal-backdrop doesn't disappear
I believe this can also be caused by calling modal('hide') before the fade animation has fully completed. Removing the fade class from the...
Read more >Modal - Bootstrap
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >react-native-modal - npm
The modal is controlled by the isModalVisible state variable and it is initially hidden, since its value is false . Pressing the button...
Read more ><Modal/> Component - React-Bootstrap
A modal with header, body, and set of actions in the footer. Use <Modal/> in combination with other components to show or hide...
Read more >Bootstrap Modal - Examples & Tutorials. Learn how to use ...
The animation effect of this component is dependent on the ... data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Ruffio I often use modals to show status messages, for example during an ajax call: in this case I show a modal with an
.alert-infomessage “Loading…” and then at the end of the call I hide the modal. If the call is too fast the ajax callback will call the modal hide before the modal is totally shown and it won’t hide anymore. I quickly resolved this for myself because I don’t call themodal('hide')directly but I use a mask method:$(this).on('shown.bs.modal', function() { $(this).modal('hide'); }).modal('hide');but in general I thought this could happen to more users so I opened the issue.For me, it’s not an issue or a bug here, it’s a choice we made, it’s written everywhere in our documentation our methods are asynchronous (example) so you have to listen to our
events.BTW if you want to cancel an event, we have different state of events for example:
show.bs.modalandshown.bs.modal. Whenshown.bs.modalis triggered your modal is fully shown but whenshow.bs.modalis triggered your modal will be shown, so you canpreventDefaultthis event.Example: