Skip to content

Commit

Permalink
#8206: Avoid Edge crash when opening user links (#8211)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Apr 10, 2024
1 parent 4668ee9 commit 3e1a159
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/utils/openAllLinksInPopups.ts
Expand Up @@ -18,11 +18,14 @@
import excludeAltClicksEtc from "filter-altered-clicks";

const listener = excludeAltClicksEtc((event: MouseEvent) => {
// `event.target` can sometimes be an SVG path element and not an HTMLElement
const link = event.target instanceof Element && event.target.closest("a");
if (link) {
window.open(link.href);
event.preventDefault();
// `composedPath` is used to support clicks in an `open` Shadow DOM
// https://github.com/pixiebrix/pixiebrix-extension/issues/8206
for (const eventTarget of event.composedPath()) {
if (eventTarget instanceof HTMLAnchorElement) {
window.open(eventTarget.href);

This comment has been minimized.

Copy link
@twschiller

twschiller Apr 10, 2024

Contributor

@fregante does the window open close the sidebar on MV3? Do we need to use browser.tabs to create a new tab?

event.preventDefault();
return;
}
}
});

Expand Down

0 comments on commit 3e1a159

Please sign in to comment.