mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 18:17:31 +08:00
fix(vue): canGoBack method now works correctly (#24188)
resolves #24109
This commit is contained in:
@ -133,7 +133,18 @@ export const createLocationHistory = () => {
|
||||
}
|
||||
const previous = () => locationHistory[locationHistory.length - 2] || last();
|
||||
const last = () => locationHistory[locationHistory.length - 1];
|
||||
const canGoBack = (deep: number = 1) => locationHistory.length > deep;
|
||||
|
||||
/**
|
||||
* With the introduction of router.go support, we no longer remove
|
||||
* items from locationHistory as they may be needed again in the future.
|
||||
* As a result, we need to look at the current position in location history
|
||||
* to see if users can navigate back n pages. Previously we were checking
|
||||
* the length of locationHistory, but that only worked since we were pruning
|
||||
* the array.
|
||||
*/
|
||||
const canGoBack = (deep: number = 1, initialHistory: number, currentHistory: number) => {
|
||||
return currentHistory - deep >= initialHistory;
|
||||
}
|
||||
|
||||
const getFirstRouteInfoForTab = (tab: string): RouteInfo | undefined => {
|
||||
const tabHistory = getTabsHistory(tab);
|
||||
|
Reference in New Issue
Block a user