mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 21:06:04 +00:00
admin: fix back behavior to not rely on history object
This commit is contained in:
@@ -102,13 +102,29 @@ export function useNavigate() {
|
||||
}
|
||||
|
||||
const _url = options?.absolute ? `~/${basepath}${url}`.replace(/\/+/g, "/") : url;
|
||||
const state = {
|
||||
...options?.state,
|
||||
referrer: location,
|
||||
};
|
||||
|
||||
navigate(options?.query ? withQuery(_url, options?.query) : _url, {
|
||||
replace: options?.replace,
|
||||
state: options?.state,
|
||||
state,
|
||||
});
|
||||
});
|
||||
},
|
||||
location,
|
||||
(opts?: { fallback?: string }) => {
|
||||
const state = window.history.state;
|
||||
if (state?.referrer) {
|
||||
//window.history.replaceState(state, "", state.referrer);
|
||||
navigate(state.referrer, { replace: true });
|
||||
} else if (opts?.fallback) {
|
||||
navigate(opts.fallback, { replace: true });
|
||||
} else {
|
||||
window.history.back();
|
||||
}
|
||||
},
|
||||
] as const;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user