Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clicking on prevent defaulted A tags in dekstop live preview opens browser tab #1997

Merged
merged 1 commit into from
Dec 18, 2024
Merged
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
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
Loading