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

ActiveAware is called more than needed #2816

Closed
muak opened this issue Dec 4, 2022 · 2 comments · Fixed by #2848
Closed

ActiveAware is called more than needed #2816

muak opened this issue Dec 4, 2022 · 2 comments · Fixed by #2848

Comments

@muak
Copy link

muak commented Dec 4, 2022

When NavigationSegments is "/TabbedPage/NavigationPage/ContentPage",
ActiveAware method is called twice in ContentPage's ViewModel implemented IActiveAware.
This problem only occurs when the application is launched.

.OnAppStart((container,navigationService) =>
{
    navigationService.CreateBuilder()
    .AddTabbedSegment("MyTabbedPage", config =>
    {
        config
        .CreateTab(t => t.AddSegment<MyNavigationViewModel>().AddSegment<MainViewModel>())
    })
    .Navigate(HandleNavigationError);
})

The cause of this is the duplication of IsActive operations in the NavigationPageActiveAwareBehavior and the TabbedPageActiveAwareBehavior.

Perhaps this can be resolved by adapting the NavigatingPageActiveAwareBehavior after adding a child to the TabbedPage.
I think it can also be solved by applying TabbedPageActiveAwareBehavior after adding children to TappedPage.

Currently, behaviors are applied in the CreatePage method, so adding a CreatePage method that does not apply Behaviors may be a solution.

@dansiegel
Copy link
Member

Feel free to submit a PR... also please be sure to add a test that validates the scenario that you're making the change for

@muak
Copy link
Author

muak commented Dec 18, 2022

@dansiegel
Thank you for the reply.
I will create a PR, when I can fix it.

@dansiegel dansiegel transferred this issue from PrismLibrary/Prism.Maui Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants