Merge pull request #220 from DioxusLabs/jk/outerlinking

fix: always prevent default on `A` tags in desktop
This commit is contained in:
Jonathan Kelley 2022-02-08 15:10:36 -05:00 committed by GitHub
commit 82b0e6c8d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -204,12 +204,18 @@ export class Interpreter {
// todo call prevent default if it's the right type of event
if (shouldPreventDefault !== `onclick`) {
if (target.tagName == "A") {
event.preventDefault();
const href = target.getAttribute("href");
if (href !== "" && href !== null && href !== undefined) {
window.rpc.call("browser_open", { href });
}
}
}
// also prevent buttons from submitting
if (target.tagName == "BUTTON") {
event.preventDefault();
}
}
// walk the tree to find the real element
while (realId == null) {