mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Fix: when page disappears because parent viewController is removed (e.g. selecting different tab in TabBar) our navigation stack was incorrectly removing backstack entry. This fix may not work if the tab is hosted in Page but it is unlikely that someone will host Page->TabView->Frame->Page
This commit is contained in:
@ -190,8 +190,13 @@ class UIViewControllerImpl extends UIViewController {
|
||||
}
|
||||
|
||||
const frame = owner.frame;
|
||||
// Skip navigation events if we are hiding because we are about to show modal page.
|
||||
// Skip navigation events if we are hiding because we are about to show modal page
|
||||
// or because we are in tab and another controller is selected.
|
||||
const tab = this.tabBarController;
|
||||
if (!owner._presentedViewController && frame && frame.currentPage === owner) {
|
||||
const willSelectViewController = tab && (<any>tab)._willSelectViewController;
|
||||
if (!willSelectViewController
|
||||
|| willSelectViewController === tab.selectedViewController) {
|
||||
let isBack = isBackNavigationFrom(this, owner);
|
||||
owner.onNavigatingFrom(isBack);
|
||||
}
|
||||
@ -225,8 +230,16 @@ class UIViewControllerImpl extends UIViewController {
|
||||
const frame = page.frame;
|
||||
// We are not modal page, have frame with backstack and navigation queue is empty and currentPage is closed
|
||||
// then pop our backstack.
|
||||
// If we are in frame wich is in tab and tab.selectedControler is not the frame
|
||||
// skip navigation.
|
||||
const tab = this.tabBarController;
|
||||
const fireNavigationEvents = !tab
|
||||
|| tab.selectedViewController === this.navigationController;
|
||||
|
||||
if (!modalParent && frame && frame.backStack.length > 0 && frame.navigationQueueIsEmpty() && frame.currentPage === page) {
|
||||
(<any>frame)._backStack.pop();
|
||||
if (fireNavigationEvents) {
|
||||
(<any>frame)._backStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
page._enableLoadedEvents = true;
|
||||
@ -247,7 +260,7 @@ class UIViewControllerImpl extends UIViewController {
|
||||
|
||||
page._enableLoadedEvents = false;
|
||||
|
||||
if (!modalParent) {
|
||||
if (!modalParent && fireNavigationEvents) {
|
||||
// Last raise onNavigatedFrom event if we are not modally shown.
|
||||
page.onNavigatedFrom(isBack);
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl
|
||||
owner._handleTwoNavigationBars(backToMoreWillBeVisible);
|
||||
}
|
||||
|
||||
(<any>tabBarController)._willSelectViewController = viewController;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -71,6 +73,8 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl
|
||||
if (owner) {
|
||||
owner._onViewControllerShown(viewController);
|
||||
}
|
||||
|
||||
(<any>tabBarController)._willSelectViewController = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user