question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modal doesn't hide if hide is called during show animation

See original GitHub issue

Hi, 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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
maestroosramcommented, Aug 16, 2017

@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-info message “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 the modal('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.

1reaction
Johann-Scommented, Aug 23, 2018

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.modal and shown.bs.modal. When shown.bs.modal is triggered your modal is fully shown but when show.bs.modal is triggered your modal will be shown, so you can preventDefault this event.

Example:

var $myModal = $('#myModal')
$myModal.on('show.bs.modal', function (event) {
  event.preventDefault();
  // your modal won't show
})
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found