Skip to content

Commit

Permalink
feat(toast): allow clickable items without closing
Browse files Browse the repository at this point in the history
Some content inside toasts should remain clickable without closing the toast. (even if closeOnClick is true)
While this was already hardcoded for a tags if fails for possible other tags like accordion or details (Especially when used together with the new #2197 😉 )
The previously hardcoded selector is not a customizable classname setting.

Btw: input is not needed to be set here, because any kind of input inside a toast will already set the whole toast to not closing when clicked (because it is expected to be clicked into the input fields).
The new setting here is supposed for elements which can be clicked, but are not expected to.
  • Loading branch information
lubber-de authored Jan 8, 2022
1 parent adc8d1a commit 5c02143
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/definitions/modules/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ $.fn.toast = function(parameters) {
module.close();
},
click: function(event) {
if($(event.target).closest('a').length === 0) {
if($(event.target).closest(selector.clickable).length === 0) {
if(settings.onClick.call($toastBox, element) === false || !settings.closeOnClick) {
module.verbose('Click callback returned false or close denied by setting cancelling close');
return;
Expand Down Expand Up @@ -876,6 +876,7 @@ $.fn.toast.settings = {
image : '> img.image, > .image > img',
icon : '> i.icon',
input : 'input:not([type="hidden"]), textarea, select, button, .ui.button, ui.dropdown',
clickable : 'a, details, .ui.accordion',
approve : '.actions .positive, .actions .approve, .actions .ok',
deny : '.actions .negative, .actions .deny, .actions .cancel'
},
Expand Down

0 comments on commit 5c02143

Please sign in to comment.