@homebound/beam 4.9.1 → 4.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +10 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28946,6 +28946,7 @@ function useUnsavedChangesGuard(options) {
|
|
|
28946
28946
|
isDirtyRef.current = isDirty;
|
|
28947
28947
|
const allowNavigationRef = useRef74(allowNavigation);
|
|
28948
28948
|
allowNavigationRef.current = allowNavigation;
|
|
28949
|
+
const allowCancelNavigationRef = useRef74(false);
|
|
28949
28950
|
useEffect40(() => {
|
|
28950
28951
|
const onBeforeUnload = (e) => {
|
|
28951
28952
|
if (isDirtyRef.current?.()) {
|
|
@@ -28956,8 +28957,16 @@ function useUnsavedChangesGuard(options) {
|
|
|
28956
28957
|
return () => window.removeEventListener("beforeunload", onBeforeUnload);
|
|
28957
28958
|
}, []);
|
|
28958
28959
|
const blocker = useBlocker((args) => {
|
|
28960
|
+
if (allowCancelNavigationRef.current) {
|
|
28961
|
+
return false;
|
|
28962
|
+
}
|
|
28959
28963
|
return !!isDirtyRef.current?.() && !allowNavigationRef.current?.(args);
|
|
28960
28964
|
});
|
|
28965
|
+
const confirmCancel = (e) => {
|
|
28966
|
+
allowCancelNavigationRef.current = true;
|
|
28967
|
+
onCancel(e);
|
|
28968
|
+
allowCancelNavigationRef.current = false;
|
|
28969
|
+
};
|
|
28961
28970
|
const onCancelClick = (e) => {
|
|
28962
28971
|
if (!isDirty?.()) {
|
|
28963
28972
|
onCancel(e);
|
|
@@ -28965,7 +28974,7 @@ function useUnsavedChangesGuard(options) {
|
|
|
28965
28974
|
}
|
|
28966
28975
|
openModal({
|
|
28967
28976
|
allowClosing: false,
|
|
28968
|
-
content: /* @__PURE__ */ jsx237(ConfirmCloseModal, { onClose: () =>
|
|
28977
|
+
content: /* @__PURE__ */ jsx237(ConfirmCloseModal, { onClose: () => confirmCancel(e) })
|
|
28969
28978
|
});
|
|
28970
28979
|
};
|
|
28971
28980
|
const navigationBlocker = blocker.state === "blocked" ? { proceed: () => blocker.proceed?.(), cancelNavigation: () => blocker.reset?.() } : void 0;
|