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] onApprove cannot prevent hiding when modal is created with JS API.

See original GitHub issue

Bug 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

  1. Create modal with JS API
  2. Show modal
  3. 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:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
lubber-decommented, Sep 17, 2021

Fixed by #2108

2reactions
lubber-decommented, Sep 16, 2021

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 to green 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 the onapprove 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/

Read more comments on GitHub >

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

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