Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] The NavigationBar fails to refresh when the existing child of a TabbedPage is substituted with a different NavigationPage. #22824

Open
HMorales-ChipSoft opened this issue Jun 4, 2024 · 4 comments
Assignees
Labels
area-controls-tabbedpage TabbedPage area-navigation NavigationPage migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@HMorales-ChipSoft
Copy link

HMorales-ChipSoft commented Jun 4, 2024

Description

Hi,

In our scenario, every tab within the TabbedPage contains a distinct NavigationPage. However, when an existing NavigationPage is substituted with a new one, the NavigationBar ceases to refresh. It's important to note that this issue only occurs when the TabbedPage is presented as a Modal. On iOS, the functionality operates as anticipated.

Steps to Reproduce

I have composed the following code to replicate our scenario:

image

The MainPage includes a button. When pressed, another MainPage will be presented as a Modal, and the scenario described above will repeat.

Expected Behavior
ReproNavigationBarXF

Actual Behavior
ReproNavigationBarMaui

Link to public reproduction project repository

https://github.com/HMorales-ChipSoft/Maui_Issues/tree/main/ReproMaui

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows

Affected platform versions

No response

Did you find any workaround?

Unfortunately no.

Relevant log output

No response

@HMorales-ChipSoft HMorales-ChipSoft added the t/bug Something isn't working label Jun 4, 2024
Copy link
Contributor

github-actions bot commented Jun 4, 2024

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.

@PureWeen PureWeen added the migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert label Jun 4, 2024
@ninachen03 ninachen03 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jun 5, 2024
@ninachen03
Copy link

Verified this issue with Visual Studio 17.11.0 Preview 1.1(8.0.40 & 8.0.3). Can repro on android platform with sample project.

@HMorales-ChipSoft
Copy link
Author

Any progression or workaround?

@NanthiniMahalingam
Copy link
Contributor

Sample level fix

• When dynamically adding a new tapped page to the root of the content page, we can use the PushModalAsync method because content page is not possible to set the tapped page.
• If we need to push another navigation page onto the tapped page, we must create a new instance of the tapped page using the existing instance, then add the navigation page and its content.
• After initializing tapped page, we can push the navigation page using PushModalAsync method.
• Now, the first and second navigation pages are updated by providing a task delay duration.

public class MainPageViewModel
{
        public MainPageViewModel()
        {
                ShowModalCommand = new Command(async obj =>
                {
                        Microsoft.Maui.Controls.TabbedPage tabbedPage = new Microsoft.Maui.Controls.TabbedPage
                        {
                                Children =
                                        {
                                                new NavigationPage(new MainPage { Title = "Main_Start_Modal_NavigationBar" }) { BarBackgroundColor = Colors.Red,  Title = "Start_Modal_NavigationBar"  }
                                        }
                        };

        //tabbedPage.On<Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetToolbarPlacement(ToolbarPlacement.Bottom);

        if (Microsoft.Maui.Controls.Application.Current?.MainPage?.Navigation is INavigation navigation)
        {
                await navigation.PushModalAsync(tabbedPage);
        }

        await Task.Delay(3000);

        tabbedPage = new Microsoft.Maui.Controls.TabbedPage
        {
                Children =
                        {
                                new NavigationPage(new MainPage { Title = "Main_New_Modal_NavigationBar" }) { BarBackgroundColor = Colors.Green,  Title = "New_Modal_NavigationBar"  }
                        }
        };

        // tabbedPage.Children[0] = new NavigationPage(new MainPage { Title = "Main_New_Modal_NavigationBar" }) { BackgroundColor = Colors.Yellow , Title = "New_Modal_NavigationBar" };

        if (Microsoft.Maui.Controls.Application.Current?.MainPage?.Navigation is INavigation navigation1)
        {
                await navigation1.PushModalAsync(tabbedPage);
        }

        });
        }

        public ICommand ShowModalCommand { get; set; }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-tabbedpage TabbedPage area-navigation NavigationPage migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants