maui icon indicating copy to clipboard operation
maui copied to clipboard

Ambiguous route when PopModalAsync

Open sinsedrix opened this issue 1 year ago • 5 comments

Description

When calling PopModalAsync, the navigation fails to go back to the calling page.

Ambiguous routes matched for: //IMPL_MainPage/IMPL_MainPage/MainPage/TestPage matches found: //IMPL_MainPage/IMPL_MainPage/MainPage/TestPage,//IMPL_MainPage/IMPL_MainPage/MainPage/TestPage Arg_ParamName_Name

Steps to Reproduce

  1. Run reprodution project
  2. Click "Go to test page"
  3. Click "Go to choice page"
  4. Click on a choice
  5. See unexpected error

Link to public reproduction project repository

https://github.com/sinsedrix/MauiTests/tree/main/Modal

Version with bug

8.0.3 GA

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

  • Windows
  • Android emulator

Affected platform versions

net8.0-windows10.0.19041.0

Did you find any workaround?

no

Relevant log output

System.ArgumentException
  HResult=0x80070057
  Message=Ambiguous routes matched for: //IMPL_MainPage/IMPL_MainPage/MainPage/TestPage matches found: //IMPL_MainPage/IMPL_MainPage/MainPage/TestPage,//IMPL_MainPage/IMPL_MainPage/MainPage/TestPage Arg_ParamName_Name
  Source=Microsoft.Maui.Controls
  Arborescence des appels de procédure :
   à Microsoft.Maui.Controls.ShellUriHandler.GetNavigationRequest(Shell shell, Uri uri, Boolean enableRelativeShellRoutes, Boolean throwNavigationErrorAsException, ShellNavigationParameters shellNavigationParameters)
   à Microsoft.Maui.Controls.ShellNavigationManager.<GoToAsync>d__14.MoveNext()
   à Microsoft.Maui.Controls.Shell.NavigationImpl.<OnPopModal>d__10.MoveNext()
   à Modal.ShellExt.<PopModalAsync>d__2.MoveNext() dans C:\wk\Tests\MauiTests\Modal\ShellExt.cs :ligne 24
   à Modal.ViewModels.BaseModalVm`1.<>c__DisplayClass4_0.<<GetResultAsync>b__0>d.MoveNext() dans C:\wk\Tests\MauiTests\Modal\ViewModels\BaseModalVm.cs :ligne 16

sinsedrix avatar Apr 02 '24 13:04 sinsedrix

Verified this issue with Visual Studio 17.10.0 preview2 (8.0.14). Can repro on windows and android platforms with sample project. image

Zhanglirong-Winnie avatar Apr 03 '24 01:04 Zhanglirong-Winnie

Any workaround would be welcome...

sinsedrix avatar Apr 24 '24 08:04 sinsedrix

you have two things registered to "MainPage" https://github.com/sinsedrix/MauiTests/blob/main/Modal/MauiProgram.cs#L22 https://github.com/sinsedrix/MauiTests/blob/main/Modal/AppShell.xaml#L13

PureWeen avatar May 07 '24 08:05 PureWeen

I see this same problem without registering the same route twice if I have a base page which opens a page with PushModalAsync (new VM1()) which then opens a different page with PushModalAsync(new VM2) and then that last page attempts to call PopModalAsync()

Saurbaum avatar May 07 '24 15:05 Saurbaum

Ambiguous routes matched for: //IMPL_LocalLAPTOP/IMPL_LocalLAPTOP/LocalLAPTOP/D_FAULT_BrowseDatabasePage14 matches found: //IMPL_LocalLAPTOP/IMPL_LocalLAPTOP/LocalLAPTOP/D_FAULT_BrowseDatabasePage14,//IMPL_LocalLAPTOP/IMPL_LocalLAPTOP/LocalLAPTOP/D_FAULT_BrowseDatabasePage14 (Parameter 'uri')

Saurbaum avatar May 07 '24 15:05 Saurbaum

you have two things registered to "MainPage" https://github.com/sinsedrix/MauiTests/blob/main/Modal/MauiProgram.cs#L22 https://github.com/sinsedrix/MauiTests/blob/main/Modal/AppShell.xaml#L13

Could you check it?

jsuarezruiz avatar Jun 13 '24 08:06 jsuarezruiz

I run into the same issue if I navigate to a page using Application.Current.MainPage.Navigation.PushAsync(page); and then call await Shell.Current.Navigation.PopAsync(); trying to go back. This page is not registered in my AppShell.xaml because I don't want it showing up in the main navigation. If I register the route and set IsVisible to false, it can't find the route and crashes.

davidgriffithfm avatar Jul 05 '24 09:07 davidgriffithfm