Absolute Navigation hack for Android results in an extra Window causing other side effects
jBijsterboschNL opened this issue · comments
When using absolute navigation this results (at least on Android) in a 2nd window being added. This should not be the case I guess?
After researching the code, I've found an Android hack for absolute navigation which is causing this (in PageNavigationService.DoPush() at line 913).
Reproduction steps:
- Open the Prism.Maui demo app
- Replace the OnAppearing() implementation for:
public async void OnAppearing()
{
await Task.Delay(3000);
await _navigationService.CreateBuilder()
.AddNavigationSegment<RootPageViewModel>()
.UseAbsoluteNavigation()
.NavigateAsync();
await Task.Delay(10000);
var windowsCount = Application.Current?.Windows.Count;
}
- Run the code and check/debug windowsCount (it is 2 where it shouldn't)
After changing the PageNavigationService, removing the Android hack it seems not to happen. Perhaps the .NET MAUI bug is resolved in the stable release?
@dansiegel do you have a (unit) test/scenario where this hack was needed for? Could you perhaps validate removing this hack is possible here? I'll create a pull request for the code change so you are able to validate this.
original issue in question dotnet/maui#7275 was resolved, could the hack be safely removed now?
I'd love to this be done too, as we currently can't use Absolute Navigation successfully.
the navigation hack has been removed for .NET 7... NOTE: You will need to update your application to inherit from PrismApplication to handle the initial navigation event.