Bug in modal.js: defaultPrevented called on jQuery.Event instead of isDefaultPrevented()
See original GitHub issueTried to prevent the hidePrevented.bs.modal event using e.preventDefault(), but it won’t work since the code checks for defaultPrevented instead of isDefaultPrevented().
The bug on this line: https://github.com/twbs/bootstrap/blob/v4.5.2/js/src/modal.js#L237
All the other events are properly using isDefaultPrevented() see for example this line: https://github.com/twbs/bootstrap/blob/v4.5.2/js/src/modal.js#L117
Here’s a simple fix: https://github.com/twbs/bootstrap/compare/v4.5.2...joakimriedel:joakimriedel/defaultPrevented?expand=1
Patch for 4.5.2 ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
event.preventDefault() | jQuery API Documentation
We can use event.isDefaultPrevented() to determine if this method has been called by an event handler that was triggered by this event.
Read more >Why is event.defaultPrevented undefined? - Stack Overflow
However, in my code, defaultPrevented is undefined (Chrome and Safari). Instead there is another property called: isDefaultPrevented which seems ...
Read more >www.chulavistaconvis.com/dynamic/js/home.aspx
_Deferred(); // Catch cases where $(document).ready() is called after the ... isDefaultPrevented() ) { var old, special = jQuery.event.special[ type ] ...
Read more >https://www.icaro2000.com/fallback/js/bootstrap.bu...
jQuery must be included before Bootstrap\\'s JavaScript. ... preventDefault() // work around Firefox bug #1540995\n return\n }\n\n if (initialButton.
Read more >When to actually use preventDefault(), stopPropagation(), and ...
Some people have suggested to call preventDefault() and use 'e.defaultPrevented' to not handle an event instead of stopPropagation().
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

Thanks for the bug report and the PR. #31696 was merged.
@XhmikosR sure https://github.com/twbs/bootstrap/pull/31696