Prism icon indicating copy to clipboard operation
Prism copied to clipboard

[BUG] Popup Dialog does not open when called from a Service after using Absolute Navigation.

Open askariya opened this issue 1 year ago • 0 comments

Description

I have a service that handles showing popup dialogs using Prism's dialog service. When I navigate to a page via Absolute Navigation, then trigger the popups from my custom popup service, the Prism Dialogs stop working. As far as I can tell, the ShowDialogAsync() call never seems to return.

Popups work just fine before any Absolute Navigation. I even tried doing absolute navigation back to the same page I was on and opening popups after, the issue still occurs once the Absolute Navigation happens.

  • Here is a link to a sample project where you can reproduce the issue: https://github.com/askariya/MauiPrismDialogErrorDemoApp
  • Here is a video of how I reproduced the issue: https://github.com/user-attachments/assets/bba1b4bd-a7e7-454b-8f44-7e915a1b77ff

Note: I found that if I set prism.ConfigureMopupDialogs(), then it works fine. You can control that with an ifdef I added in the MauiProgram.cs.

Steps to Reproduce

You can follow the steps in this video: https://github.com/user-attachments/assets/bba1b4bd-a7e7-454b-8f44-7e915a1b77ff It shows popups being called directly from the viewmodel (LOCAL button) and from my service (SERVICE button).

The steps for reproducing are also below:

  1. Ensure prism.ConfigureMopupDialogs() is NOT set in your MauiProgram.cs when doing UsePrism(...).
  2. Navigate to a page with NavigationBuilder and include the UseAbsoluteNavigation() function. Note: CreateWindow can use Absolute Navigation without this issue occurring. var navResult = await _navigationService.CreateBuilder() .UseAbsoluteNavigation() .AddNavigationPage() .AddSegment<SecondPageViewModel>() .NavigateAsync();
  3. On the page that was navigated to, call the popup from a Service and not directly from a ViewModel.

When I do the above, the popup does not appear and the code never seems to return from the ShowDialogAsync() call.

Platform with bug

.NET MAUI

Affected platforms

Android

Did you find any workaround?

  • Utilizing Mopup Dialogs with prism.ConfigureMopupDialogs() appears to work in this scenario.
  • Calling the Popup from the ViewModel directly instead of a Service will also avoid the issue.

Relevant log output

No response

askariya avatar Jul 24 '24 20:07 askariya