You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Show alert message only when isPageDirty is true
if(isPageDirty.value)e.preventDefault()
}
consthandleBeforeUnload=(e: BeforeUnloadEvent)=>{// Show alert message only when isPageDirty is trueif(isPageDirty.value){e.preventDefault()e.returnValue='';}}
It looks like the
e.preventDefault()
is not enough in some browsers (Brave is where I tested).However, if I also do
e.returnValue = ''
, it does prevent and ask if I really want to close the tab.This would be an easy fix:
vue-use-kit/src/functions/useBeforeUnload/useBeforeUnload.ts
Lines 6 to 9 in 584bc1a
Source: https://community.plumsail.com/t/any-way-to-prevent-user-from-closing-tab-or-showing-a-warning-before-they-close-it-from-within-forms/10261/8
The text was updated successfully, but these errors were encountered: