dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.28k stars 1.76k forks source link

Navigation - Shell TabBar Doesnt render Content when navigating from and then back to it #26144

Open corne-ac opened 1 day ago

corne-ac commented 1 day ago

https://github.com/user-attachments/assets/3226c4a0-7799-4749-926a-6417ed9c9697

Description

So basically, scenario, we have a Mainpage, and from this Mainpage the user navigates to a tabbed page, this login and tabbed page is registered in the AppShell.Xaml. the tabbed page, is another shell containing a TabBar with multiple pages. When the user navigates from the main page, to the tabbed page, back to main page, and Again to the Tabbed page, the page content doesnt render anymore. Its a niche scenario but it is currently causing issues in our application. I have created a sample project that I was able to successfully recreate the issue in.

Steps to Reproduce

  1. Create an empty project

  2. on the AppShell.Xaml, register this:

    <ShellContent
        Title="Main Page"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="MainPage" />
    
    <TabBar>
        <Tab Route="DashboardPage">
            <ShellContent
                Title="Dashboard"
                ContentTemplate="{DataTemplate local:DashboardPage}"/>
        </Tab>
    
    </TabBar>
  3. On the dashboardPage, xaml:

<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:navBugTest="clr-namespace:NavBugTest"
             x:Class="NavBugTest.DashboardPage">
    <TabBar>
        <Tab
            x:Name="HomeTab"
            Title="Home"
            Icon="home">
            <ShellContent ContentTemplate="{DataTemplate navBugTest:HomePage}" Route="HomePage" />
        </Tab>
        <Tab
            x:Name="SecondTab"
            Title="Home"
            Icon="home">
            <ShellContent ContentTemplate="{DataTemplate navBugTest:HomePage}" Route="HomePage" />
        </Tab>
    </TabBar>
</Shell>
  1. And on the HomePage Xaml, just some content, same with the MainPage.
  2. Add buttons on the mainpage and homepage to navigate between the dashboardpage and the mainpage

Link to public reproduction project repository

https://github.com/corne-ac/Maui-Navigation-Bug

Version with bug

8.0.100 SR10

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 35

Did you find any workaround?

No

Relevant log output

similar-issues-ai[bot] commented 1 day ago

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

kevinxufei commented 1 day ago

I can repro this issue at Android platform on the latest 17.13 Preview 1(8.0.93 & 8.0.100).