Xamarin.forms: [Bug] Shell cancel navigation doesn't work for top bar navigation on android

Created on 27 Mar 2020  路  2Comments  路  Source: xamarin/Xamarin.Forms

When navigating between top tabs in a shell app, Overriding OnNavigating(ShellNavigatingEventArgs args) and calling args.Cancel() doesn't stop navigation to the new tab on Android, iOS is fine.

Description

Steps to Reproduce

  1. Load the test project from the zip I uploaded (bin and obj deleted, make sure to rebuild),
  2. Run in iOS
  3. Navigate to the tab called "About Locked", you can't get there as expected as per logic in AppShell.xaml.cs
  4. Load the project in Android
  5. Navigate to the tab called "About Locked", you can navigate there when you shouldn't be able to

Expected Behavior

args.Cancel() should stop navigation on Android from a top bar tab to another

Actual Behavior

It doesn't

Basic Information

  • Version with issue: 4.5
  • Last known good version: N/a
  • IDE: VS 2019
  • Platform Target Frameworks:

    • Android: API 28 Pie
  • Affected Devices: All android devices

Reproduction Link

TestShellBehaviour.zip

Logic for locking the tab

        protected override void OnNavigating(ShellNavigatingEventArgs args)
        {

            base.OnNavigating(args);
            if (args.Target.Location.OriginalString.Contains("AboutLocked"))
            {
                args.Cancel();
            }

        }

Workaround

I didn't find one yet

2 in-progress bug

All 2 comments

@PureWeen @samhouts It's really cool to see how my issue went from bug report to fix to major-version-released in just a single month. Loving xam forms and thanks very much!

Yay!! Thank you for logging this issue @AdamDiament

Happy to see this change is working out for you. There were a lot of good improvements to navigation that came from working on this one.

Was this page helpful?
0 / 5 - 0 ratings