show.bs.modal
test case – V4.0.0Issue: Modal event.preventDefault() for show.bs.modal: disables modal with fade class from being displayed again in V4 & V5.
The JavaScript for Bootstrap V4 & V5 stops a modal from being displayed again, once displaying the modal has been prevented using event.preventDefault()
.
This JS Bin using Bootstrap V4.0.0 shows event.preventDefault()
not working as expected after a modal has been prevented from displaying:
show.bs.modal
event.event.preventDefault()
and nothing is displayed.The action of the modal button can be confirmed through the developer console. As the listener is sent an event, the listener will log the button and the switch status. An action will be logged every time the button is clicked, so long as the switch is set to enabled. Once the switch is changed to disabled, only one more event will be logged. After that, the modal listener will not be sent any more events.
To step through the Bootstrap code, a breakpoint can be placed at line 109 in the modal.js file (the show(relatedTarget)
function).