mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: prevent route change on canceling confirm dialog (#4493)
This commit is contained in:
parent
8fae076fd6
commit
c054b18ad5
@ -16,14 +16,15 @@ const useReloadConfirmations = (isActive = true) => {
|
||||
);
|
||||
|
||||
const handleRouteChangeStart = useCallback(
|
||||
(url: string) => {
|
||||
(url: string, { shallow }: { shallow: boolean }) => {
|
||||
if (!isActive || !showAlert) return;
|
||||
const leave = confirm("Are you sure you want to leave? Changes you made may not be saved.");
|
||||
if (!leave) {
|
||||
router.events.emit("routeChangeError");
|
||||
router.events.emit("routeChangeError", new Error("Route change cancelled by user"), url, shallow);
|
||||
throw "routeChange aborted.";
|
||||
}
|
||||
},
|
||||
[isActive, showAlert, router.events]
|
||||
[isActive, router.events, showAlert]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user