Skip to content

Commit

Permalink
fix: clicking on prevent defaulted A tags in dekstop live preview ope…
Browse files Browse the repository at this point in the history
…ns browser tab
  • Loading branch information
abose committed Dec 18, 2024
1 parent 37ffb53 commit ca16b50
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/LiveDevelopment/BrowserScripts/LivePreviewTransportRemote.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,17 +304,19 @@
// an iframe(except for the intel mac bug)
// in normal browsers, we dont need to do this and the borwser will do its thing.
const href = getAbsoluteUrl(targetElement.getAttribute('href'));
window.parent.postMessage({
handlerName: "ph-liveServer",
eventName: 'embeddedIframeHrefClick',
href: href
}, "*");
// in intel mac desktop, tauri seems to open in browser
// causing 2 tabs to open. in m1 macs its not there. so we prevent default behavior.
event.stopImmediatePropagation();
event.preventDefault();
if (!event.defaultPrevented) {
window.parent.postMessage({
handlerName: "ph-liveServer",
eventName: 'embeddedIframeHrefClick',
href: href
}, "*");
// in intel mac desktop, tauri seems to open in browser
// causing 2 tabs to open. in m1 macs its not there. so we prevent default behavior.
event.stopImmediatePropagation();
event.preventDefault();
}
}
}, true);
});
document.addEventListener('contextmenu', function(event) {
(document.activeElement || document.body).focus();
});
Expand Down

0 comments on commit ca16b50

Please sign in to comment.