Skip to content

Commit cb5be9a

Browse files
Ignore clicks on elements inside (Mavo and form) controls when triggering actions (#1037)
Fixes #1036 --------- Co-authored-by: Lea Verou <[email protected]>
1 parent dfe3149 commit cb5be9a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/actions.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ Mavo.attributes.push("mv-action");
44

55
let _ = Mavo.Actions = {
66
listener: evt => {
7+
// Clicking elements inside these elements should be ignored
8+
// if the target element is closer to them than to the [mv-action] element
9+
let controlSelector = `
10+
.mv-ui, .mv-editor, .mv-popup, .mv-drag-handle,
11+
button, label, input, output, select, textarea, meter, progress
12+
`;
13+
714
let tag = evt.type === "submit"? "form" : ":not(form)";
815
let element = evt.target.closest(tag + "[mv-action]");
16+
let control = evt.target.closest(tag + `:is(${ controlSelector })`);
917

10-
if (!element) {
11-
return; // Not an action
18+
if (!element || control && !control.contains(element)) {
19+
return; // Not an action or the click should be ignored
1220
}
1321

1422
let node = Mavo.Node.get(element);

0 commit comments

Comments
 (0)