Skip to content

Maui Shell weird navigation issue with timing of ApplyQueryAttributes and Page Lifecycle #24241

@meopoc

Description

@meopoc

Description

My app navigates to a MainPage with a menu that then navigates through other pages in the app until it reaches a page that requires a Flyout Menu (at which point I set the Shell.Current.FlyoutContent).

So

MainPage > PageA > PageB > PageWithFlyoutMenu

I'm performing the navigation as follows

MainPage to PageA:
await Shell.Current.GoToAsync($"PageA", true);

Lifecycle event order:
Constructor > ApplyQueryAttributes > OnAppearing > OnNavigatedTo

PageA to PageB:
await Shell.Current.GoToAsync($"PageB");

Lifecycle event order:
Constructor > ApplyQueryAttributes > OnAppearing > OnNavigatedTo

PageB to PageWithFlyoutMenu:
Shell.Current.FlyoutContent = IPlatformApplication.Current?.Services.GetService<MenuPage>();
await Shell.Current.GoToAsync($"///PageWithFlyoutMenu-1");

Lifecycle event order:
Constructor > OnAppearing > OnNavigatedTo > ApplyQueryAttributes

The issue here is that ApplyQueryAttributes is the last to be invoked.

AppShell is as follows:

<Shell
x:Class="****.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:****.Views"
xmlns:localDetail="clr-namespace:****.Views.DetailPages"
Title="****">

<ShellContent
    Title="MainPage"
    ContentTemplate="{DataTemplate local:MainPage}"
    FlyoutItemIsVisible="False"
    Route="MainPage"
    Shell.FlyoutItemIsVisible="False" />

<ShellContent
    Title="PageWithFlyoutMenu-1"
    ContentTemplate="{DataTemplate localDetail:PageWithFlyoutMenu-1}"
    Route="PageWithFlyoutMenu-1" />

<ShellContent
    Title="PageWithFlyoutMenu-2"
    ContentTemplate="{DataTemplate localDetail:PageWithFlyoutMenu-2}"
    Route="PageWithFlyoutMenu-2" />

</Shell>

And I have the following routes registered:

Routing.RegisterRoute("PageA", typeof(PageA));
Routing.RegisterRoute("PageB", typeof(PageB));

Can anyone shed any light on why this would be?

Thanks in advance

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.20 SR4

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 14

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-lifecycleXPlat and Native UIApplicationDelegate/Activity/Window lifecycle eventsp/2Work that is important, but is currently not scheduled for releasepartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/androids/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions