Skip to content

Commit ca16b50

Browse files
committed
fix: clicking on prevent defaulted A tags in dekstop live preview opens browser tab
1 parent 37ffb53 commit ca16b50

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/LiveDevelopment/BrowserScripts/LivePreviewTransportRemote.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,17 +304,19 @@
304304
// an iframe(except for the intel mac bug)
305305
// in normal browsers, we dont need to do this and the borwser will do its thing.
306306
const href = getAbsoluteUrl(targetElement.getAttribute('href'));
307-
window.parent.postMessage({
308-
handlerName: "ph-liveServer",
309-
eventName: 'embeddedIframeHrefClick',
310-
href: href
311-
}, "*");
312-
// in intel mac desktop, tauri seems to open in browser
313-
// causing 2 tabs to open. in m1 macs its not there. so we prevent default behavior.
314-
event.stopImmediatePropagation();
315-
event.preventDefault();
307+
if (!event.defaultPrevented) {
308+
window.parent.postMessage({
309+
handlerName: "ph-liveServer",
310+
eventName: 'embeddedIframeHrefClick',
311+
href: href
312+
}, "*");
313+
// in intel mac desktop, tauri seems to open in browser
314+
// causing 2 tabs to open. in m1 macs its not there. so we prevent default behavior.
315+
event.stopImmediatePropagation();
316+
event.preventDefault();
317+
}
316318
}
317-
}, true);
319+
});
318320
document.addEventListener('contextmenu', function(event) {
319321
(document.activeElement || document.body).focus();
320322
});

0 commit comments

Comments
 (0)