fix(vue): canGoBack now returns correct result with initial load redirect (#22071)

This commit is contained in:
Liam DeBeasi
2020-09-11 11:33:16 -04:00
committed by GitHub
parent a7f564b818
commit 8227844cbc

View File

@ -31,15 +31,6 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) =>
// TODO types
let historyChangeListeners: any[] = [];
const currentRoute = router.currentRoute.value;
currentRouteInfo = {
id: generateId('routeInfo'),
pathname: currentRoute.path,
search: currentRoute.fullPath.split('?')[1] || '',
params: currentRoute.params
}
locationHistory.add(currentRouteInfo)
if (typeof (document as any) !== 'undefined') {
document.addEventListener('ionBackButton', (ev: Event) => {
(ev as any).detail.register(0, (processNextHandler: () => void) => {
@ -105,6 +96,13 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) =>
leavingLocationInfo = locationHistory.current();
}
if (!leavingLocationInfo) {
leavingLocationInfo = {
pathname: '',
search: ''
}
}
const leavingUrl = leavingLocationInfo.pathname + leavingLocationInfo.search;
if (leavingUrl !== location.fullPath) {
if (!incomingRouteParams) {