Skip to content

Commit baee454

Browse files
fix: added comment for early termination
1 parent 8fc8a62 commit baee454

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

Diff for: src/shared/utilities/interactiveElements.ts

+19-19
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,27 @@ export function interactWithFirstInteractiveElement(
4141
// Try to find and interact with elements in priority order
4242
const elementFound = interactiveElements.some(({ selector, action }) => {
4343
const element = containerElement.querySelector(selector) as HTMLElement;
44-
if (element) {
45-
switch (action) {
46-
case 'click':
47-
element.click();
48-
break;
49-
case 'focus':
50-
element.focus();
51-
break;
52-
case 'toggle':
53-
if (element instanceof HTMLDetailsElement) {
54-
element.open = !element.open;
55-
} else {
56-
element.click();
57-
}
58-
break;
59-
default:
44+
if (!element) {
45+
return false;
46+
}
47+
switch (action) {
48+
case 'click':
49+
element.click();
50+
break;
51+
case 'focus':
52+
element.focus();
53+
break;
54+
case 'toggle':
55+
if (element instanceof HTMLDetailsElement) {
56+
element.open = !element.open;
57+
} else {
6058
element.click();
61-
}
62-
return true; // Stop the loop once we've found and acted on an element
59+
}
60+
break;
61+
default:
62+
element.click();
6363
}
64-
return false;
64+
return true;
6565
});
6666

6767
// If no specific interactive element was found, try using the SELECTORS constant

0 commit comments

Comments
 (0)