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/cjs/index.js
CHANGED
|
@@ -14813,6 +14813,7 @@ const UNSAVED_CHANGES_MESSAGE = 'Any unsaved changes may be lost.';
|
|
|
14813
14813
|
let state = {
|
|
14814
14814
|
promptVisible: false,
|
|
14815
14815
|
bypassNextPop: false,
|
|
14816
|
+
fatalErrorShown: false,
|
|
14816
14817
|
};
|
|
14817
14818
|
/*------------------------------------------------------------------------*/
|
|
14818
14819
|
/* ------------------------- Helper Functions --------------------------- */
|
|
@@ -14898,6 +14899,11 @@ const handlePopState = () => {
|
|
|
14898
14899
|
state.bypassNextPop = false;
|
|
14899
14900
|
return;
|
|
14900
14901
|
}
|
|
14902
|
+
// A fatal error replaced the app: there is nothing left to go back to within
|
|
14903
|
+
// it, so let the browser leave instead of trapping the user on the error
|
|
14904
|
+
if (state.fatalErrorShown) {
|
|
14905
|
+
return;
|
|
14906
|
+
}
|
|
14901
14907
|
// Already on the home screen: nothing for us to intercept
|
|
14902
14908
|
if (!state.subpanel) {
|
|
14903
14909
|
return;
|
|
@@ -15046,6 +15052,13 @@ const useBackButton = (handleGoHomeFunc) => {
|
|
|
15046
15052
|
React.useEffect(() => {
|
|
15047
15053
|
// Mark the current entry as the home entry
|
|
15048
15054
|
window.history.replaceState(HISTORY_STATE_MARKER, '');
|
|
15055
|
+
// A fatal error (or an expired session) ends the app: drop the subpanel
|
|
15056
|
+
// so no task is left looking like it's still in progress, and stop
|
|
15057
|
+
// intercepting back navigation altogether
|
|
15058
|
+
addFatalErrorHandler(() => {
|
|
15059
|
+
state.subpanel = undefined;
|
|
15060
|
+
state.fatalErrorShown = true;
|
|
15061
|
+
});
|
|
15049
15062
|
window.addEventListener('popstate', handlePopState);
|
|
15050
15063
|
return () => {
|
|
15051
15064
|
window.removeEventListener('popstate', handlePopState);
|
|
@@ -15053,6 +15066,7 @@ const useBackButton = (handleGoHomeFunc) => {
|
|
|
15053
15066
|
state = {
|
|
15054
15067
|
promptVisible: false,
|
|
15055
15068
|
bypassNextPop: false,
|
|
15069
|
+
fatalErrorShown: false,
|
|
15056
15070
|
};
|
|
15057
15071
|
};
|
|
15058
15072
|
}, []);
|