dce-reactkit 5.0.10 → 5.0.11
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/cjs/index.js +14 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/useBackButton.tsx +20 -1
package/dist/esm/index.js
CHANGED
|
@@ -14787,6 +14787,7 @@ const UNSAVED_CHANGES_MESSAGE = 'Any unsaved changes may be lost.';
|
|
|
14787
14787
|
let state = {
|
|
14788
14788
|
promptVisible: false,
|
|
14789
14789
|
bypassNextPop: false,
|
|
14790
|
+
fatalErrorShown: false,
|
|
14790
14791
|
};
|
|
14791
14792
|
/*------------------------------------------------------------------------*/
|
|
14792
14793
|
/* ------------------------- Helper Functions --------------------------- */
|
|
@@ -14872,6 +14873,11 @@ const handlePopState = () => {
|
|
|
14872
14873
|
state.bypassNextPop = false;
|
|
14873
14874
|
return;
|
|
14874
14875
|
}
|
|
14876
|
+
// A fatal error replaced the app: there is nothing left to go back to within
|
|
14877
|
+
// it, so let the browser leave instead of trapping the user on the error
|
|
14878
|
+
if (state.fatalErrorShown) {
|
|
14879
|
+
return;
|
|
14880
|
+
}
|
|
14875
14881
|
// Already on the home screen: nothing for us to intercept
|
|
14876
14882
|
if (!state.subpanel) {
|
|
14877
14883
|
return;
|
|
@@ -15020,6 +15026,13 @@ const useBackButton = (handleGoHomeFunc) => {
|
|
|
15020
15026
|
useEffect(() => {
|
|
15021
15027
|
// Mark the current entry as the home entry
|
|
15022
15028
|
window.history.replaceState(HISTORY_STATE_MARKER, '');
|
|
15029
|
+
// A fatal error (or an expired session) ends the app: drop the subpanel
|
|
15030
|
+
// so no task is left looking like it's still in progress, and stop
|
|
15031
|
+
// intercepting back navigation altogether
|
|
15032
|
+
addFatalErrorHandler(() => {
|
|
15033
|
+
state.subpanel = undefined;
|
|
15034
|
+
state.fatalErrorShown = true;
|
|
15035
|
+
});
|
|
15023
15036
|
window.addEventListener('popstate', handlePopState);
|
|
15024
15037
|
return () => {
|
|
15025
15038
|
window.removeEventListener('popstate', handlePopState);
|
|
@@ -15027,6 +15040,7 @@ const useBackButton = (handleGoHomeFunc) => {
|
|
|
15027
15040
|
state = {
|
|
15028
15041
|
promptVisible: false,
|
|
15029
15042
|
bypassNextPop: false,
|
|
15043
|
+
fatalErrorShown: false,
|
|
15030
15044
|
};
|
|
15031
15045
|
};
|
|
15032
15046
|
}, []);
|