Skip to content

Commit

Permalink
Ignore clicks on elements inside (Mavo and form) controls when trigge…
Browse files Browse the repository at this point in the history
…ring actions (#1037)

Fixes #1036 

---------

Co-authored-by: Lea Verou <[email protected]>
  • Loading branch information
DmitrySharabin and LeaVerou authored Aug 13, 2024
1 parent dfe3149 commit cb5be9a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ Mavo.attributes.push("mv-action");

let _ = Mavo.Actions = {
listener: evt => {
// Clicking elements inside these elements should be ignored
// if the target element is closer to them than to the [mv-action] element
let controlSelector = `
.mv-ui, .mv-editor, .mv-popup, .mv-drag-handle,
button, label, input, output, select, textarea, meter, progress
`;

let tag = evt.type === "submit"? "form" : ":not(form)";
let element = evt.target.closest(tag + "[mv-action]");
let control = evt.target.closest(tag + `:is(${ controlSelector })`);

if (!element) {
return; // Not an action
if (!element || control && !control.contains(element)) {
return; // Not an action or the click should be ignored
}

let node = Mavo.Node.get(element);
Expand Down

0 comments on commit cb5be9a

Please sign in to comment.