I am currently working on an Angular 17 application and I have come across the following block of code:
@HostListener("window:beforeunload", ["$event"])
onTabClose($event: BeforeUnloadEvent) {
$event.preventDefault();
$event.returnValue = "Here is some text";
return "here is some text";
}
While testing, I noticed that when a user navigates away from the page, a confirmation dialog appears as expected. However, closing the tab does not trigger the confirmation dialog to appear. I even tried setting a breakpoint in the method, but no dialog showed up.
Could this be due to a browser security issue?