Skip to content
Snippets Groups Projects
Commit 4ea3163c authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire: Committed by Reiter, Christoph
Browse files

Add beforeunload support (VPU/Apps/Signature#7)

parent b4cd863e
No related branches found
No related tags found
No related merge requests found
......@@ -286,6 +286,23 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
onMenuItemClick(e) {
e.preventDefault();
// if not the current page was clicked we need to check if the page can be left
if (!e.currentTarget.className.includes("selected")) {
// simulate a "beforeunload" event
const event = new CustomEvent("beforeunload", {
bubbles: true,
cancelable: true,
});
const eventResult = window.dispatchEvent(event);
// if someone canceled the "beforeunload" event we don't want to leave the page
if (!eventResult) {
return;
}
}
const link = e.composedPath()[0];
const location = link.getAttribute('href');
this.router.updateFromPathname(location);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment