Skip to content

Commit ede1059

Browse files
committed
[iOS][Shell]Tab becomes blank after specific navigation pattern
1 parent 9894e0f commit ede1059

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ public override void ViewDidLoad()
117117
if (r != null)
118118
accept = ((IShellItemController)ShellItem).ProposeSection(r.ShellSection, false);
119119

120+
// Detect back navigation when the user taps on the current section
121+
if (r.ShellSection == _currentSection
122+
&& viewController is ShellSectionRenderer sectionRenderer)
123+
{
124+
sectionRenderer.popRequested = true;
125+
}
126+
120127
return accept;
121128
};
122129
}

src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance)
7070
ShellSection _shellSection;
7171
bool _ignorePopCall;
7272

73-
bool _popRequested;
73+
internal bool popRequested;
7474

7575
// When setting base.ViewControllers iOS doesn't modify the property right away.
7676
// if you set base.ViewControllers to a new array and then retrieve base.ViewControllers
@@ -109,7 +109,7 @@ public bool ShouldPopItem(UINavigationBar _, UINavigationItem __)
109109
[Export("navigationBar:didPopItem:")]
110110
[Internals.Preserve(Conditional = true)]
111111
bool DidPopItem(UINavigationBar _, UINavigationItem __)
112-
=> _popRequested || SendPop();
112+
=> popRequested || SendPop();
113113

114114
internal bool SendPop()
115115
{
@@ -394,7 +394,7 @@ protected virtual void OnNavigationRequested(object sender, NavigationRequestedE
394394

395395
protected virtual async void OnPopRequested(NavigationRequestedEventArgs e)
396396
{
397-
_popRequested = true;
397+
popRequested = true;
398398
var page = e.Page;
399399
var animated = e.Animated;
400400

@@ -435,7 +435,7 @@ async void ProcessPopToRoot()
435435

436436
protected virtual async void OnPopToRootRequested(NavigationRequestedEventArgs e)
437437
{
438-
_popRequested = true;
438+
popRequested = true;
439439
var animated = e.Animated;
440440
var task = new TaskCompletionSource<bool>();
441441
var pages = _shellSection.Stack.ToList();
@@ -597,7 +597,7 @@ public override UIViewController[] PopToViewController(UIViewController viewCont
597597
public override void PushViewController(UIViewController viewController, bool animated)
598598
{
599599
_pendingViewControllers = null;
600-
_popRequested = false;
600+
popRequested = false;
601601
if (IsInMoreTab && ParentViewController is UITabBarController tabBarController)
602602
{
603603
tabBarController.MoreNavigationController.PushViewController(viewController, animated);
@@ -610,7 +610,7 @@ public override void PushViewController(UIViewController viewController, bool an
610610

611611
public override UIViewController PopViewController(bool animated)
612612
{
613-
_popRequested = true;
613+
popRequested = true;
614614
_pendingViewControllers = null;
615615
if (IsInMoreTab && ParentViewController is UITabBarController tabBarController)
616616
{

0 commit comments

Comments
 (0)