Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions studio/src/ui/popoverMenus/PopoverManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ export class PopoverManager {
const needsListener = Boolean(this.#activePopovers.length);
if (needsListener == this.#hasBodyClickListener) return;
if (needsListener) {
document.body.addEventListener("click", this.#onBodyClick);
document.body.addEventListener("pointerdown", this.#onBodyClick);
} else {
document.body.removeEventListener("click", this.#onBodyClick);
document.body.removeEventListener("pointerdown", this.#onBodyClick);
}
this.#hasBodyClickListener = needsListener;
}
Expand All @@ -122,6 +122,8 @@ export class PopoverManager {
return;
}

e.preventDefault();

this.#activePopovers.forEach(p => {
p.close();
});
Expand Down
7 changes: 4 additions & 3 deletions test/unit/studio/src/ui/popoverMenus/PopoverManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ Deno.test({
await waitForMicrotasks();

// Clicking the popover should not close it
const mouseEvent1 = new FakeMouseEvent("click");
const mouseEvent1 = new FakeMouseEvent("pointerdown");
popover.el.dispatchEvent(mouseEvent1);

assertExists(manager.curtainEl.parentElement);
assertStrictEquals(manager.getLastPopover(), popover);

// But clicking any other element should
const mouseEvent2 = new FakeMouseEvent("click");
// But clicking any other element should close the popover and remove the curtain
const mouseEvent2 = new FakeMouseEvent("pointerdown");
document.body.dispatchEvent(mouseEvent2);
assertEquals(manager.curtainEl.parentElement, null);

Expand Down