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
21.97k stars 1.71k forks source link

Android Tabbar, clicking 4th tab opens the 5th tab #23732

Open Zachary-271 opened 1 month ago

Zachary-271 commented 1 month ago

Description

When I first open the app, and then I click on the fourth tab, it shows that it's on the 4th tab, while showing the contents of the 5th tab. This only happened to me when I clicked on the 4th tab first, if I click on any other tab first the app behaves as expected. Then, if I continue to click on the other tabs, the correct tab contents are shown, and the app behaves as expected from that point on. If the tabs in my project only have 1 or 2 items in the collectionviews, the bug doesn't occur.

https://github.com/user-attachments/assets/dc25d81a-91d4-49a0-bc5d-5f1da9969f1b

Tabbar code:

<TabbedPage
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:root="clr-namespace:MauiTabs"
    xmlns:pages="clr-namespace:MauiTabs.Pages"
    x:Class="MauiTabs.Pages.MainPage"
    xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
    android:TabbedPage.IsSwipePagingEnabled="False"
    android:TabbedPage.ToolbarPlacement="Bottom">
    <NavigationPage
        Title="Home">
        <x:Arguments>
            <pages:UserPage
                Icon="{x:Static root:Constants.FontAwesomeHome}"
                Label="home"
                x:Name="Home"/>
        </x:Arguments>
        <NavigationPage.IconImageSource>
            <FontImageSource
                FontFamily="FontAwesome-Solid"
                Glyph="{x:Static root:Constants.FontAwesomeHome}"/>
        </NavigationPage.IconImageSource>
    </NavigationPage>
    <NavigationPage
        Title="Page 2">
        <x:Arguments>
            <pages:UserPage
                Icon="2"
                Label="page2"
                x:Name="Page2"/>
        </x:Arguments>
        <NavigationPage.IconImageSource>
            <FontImageSource
                FontFamily="FontAwesome-Solid"
                Glyph="2"/>
        </NavigationPage.IconImageSource>
    </NavigationPage>
    <NavigationPage
        Title="Page 3">
        <x:Arguments>
            <pages:UserPage
                Icon="3"
                Label="page3"
                x:Name="Page3"/>
        </x:Arguments>
        <NavigationPage.IconImageSource>
            <FontImageSource
                FontFamily="FontAwesome-Solid"
                Glyph="3"/>
        </NavigationPage.IconImageSource>
    </NavigationPage>
    <NavigationPage
        Title="Page 4">
        <x:Arguments>
            <pages:UserPage
                Icon="4"
                Label="page4"
                x:Name="Page4"/>
        </x:Arguments>
        <NavigationPage.IconImageSource>
            <FontImageSource
                FontFamily="FontAwesome-Solid"
                Glyph="4"/>
        </NavigationPage.IconImageSource>
    </NavigationPage>
    <NavigationPage
        Title="Page 5">
        <x:Arguments>
            <pages:UserPage
                Icon="5"
                Label="page5"
                x:Name="Page5"/>
        </x:Arguments>
        <NavigationPage.IconImageSource>
            <FontImageSource
                FontFamily="FontAwesome-Solid"
                Glyph="5"/>
        </NavigationPage.IconImageSource>
    </NavigationPage>
</TabbedPage>

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.70 SR7

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

vyn203 commented 5 days ago

I'm also experiencing the same issue on Android. The content of the 5th tab shows up when navigating to the 4th tab for the first time after app-reload, but for some reason, the 4th tab's page code-behind is triggered instead of the 5th tab's. I've checked the Navigation stack and binding context which all shows that the current page is the 4th tab's content, even though the 5th content is appearing instead. This issue does not occur on iOS or when there is 4 or less tabs on Android. Any advice?