Skip to content

Commit

Permalink
Merge pull request #1260 from plone/pat-modal-cancelbutton
Browse files Browse the repository at this point in the history
Fix close selector for default cancel buttons
  • Loading branch information
mauritsvanrees committed Dec 9, 2022
2 parents 82a9e68 + 4905251 commit b779409
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/pat/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,16 +472,18 @@ export default Base.extend({
self.emit("before-events-setup");

// Wire up events
$(
".modal-header > .modal-close, .modal-footer > .pattern-modal-buttons > .modal-close",
self.$modal
)
.off("click")
.on("click", function (e) {
self.$modal[0].querySelectorAll(
`.modal-header > .modal-close,
.modal-footer > .pattern-modal-buttons > .modal-close,
.modal-footer [name="form.buttons.Cancel" i]`
).forEach((el) => {
$(el).off("click").on("click", (e) => {
e.stopPropagation();
e.preventDefault();
$(e.target).trigger("destroy.plone-modal.patterns");
});
});


// form
if (options.form) {
Expand Down

0 comments on commit b779409

Please sign in to comment.