[Modal] onApprove cannot prevent hiding when modal is created with JS API.
See original GitHub issueBug Report
As per documentation (and module code), if onApprove
callback returns false
then modal should not be hidden on clicking approval button. But it still hides.
onApprove
return value checked in: https://github.com/fomantic/Fomantic-UI/blob/e39a0ae5183c12808ba1eee82082efbb15f4d450/src/definitions/modules/modal.js#L322
Steps to reproduce
- Create modal with JS API
- Show modal
- Click approval button
Expected result
Modal should not be hide.
Actual result
Modal hides.
Testcase
https://jsfiddle.net/pbcr1qL5/5/
Version
2.8.8
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
SemanticUI modal not onDeny/onApprove events not firing
I have problem with SemanticUI modal panel module, ...
Read more >Modal | Fomantic-UI Docs
A modal displays content that temporarily blocks interactions with the main view of a site.
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 >JavaScript SDK reference - PayPal Developer
The PayPal JavaScript SDK dynamically exposes objects and methods, based on components you are using. These components are configured in the ...
Read more >UI Modal
Use Dimmer's Behavior API to retrieve a reference to the dimmer DOM element ... Only hide modal if onDeny or onApprove return true....
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 FreeTop 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
Top GitHub Comments
Fixed by #2108
Confirmed. Also happens with
onDeny
Reason explained
Actions provided via JS parameters do have a default click handler to hide the modal if no click handler is given or, if given, does not return false.
The
onApprove
event in this case is triggered additionally, because this was originally invented to auto attach events to pre-existing action buttons in a modal already created in the DOM tree.So, your buttons have actually 2 handlers, the onapprove was indeed not hiding the modal, but the automatically created button trigger was (because you did not provide a click handler for the action button.
We will create a fix for this.
In the meantime you can use one of the following workarounds
a) Change the color from
positive
togreen
and use a click handler instead ot the onApprove callback https://jsfiddle.net/lubber/np2bdLew/7/b) Add a click handler to your
positive
action which returns false and still use theonapprove
callback https://jsfiddle.net/lubber/np2bdLew/6/c) Keep your
positive
class, but set the internal selector for approve buttons to something not existing like a space string https://jsfiddle.net/lubber/np2bdLew/10/