Mopups are hidden in background when called after MAUI FilePicker
Description
All Mopups appear to be hidden in the background when called after a FilePicker. This means the Mopup can't be closed at all so the app itself becomes impossible to interact with. To the naked eye it looks like the popup just never appears and the app freezes, but if you step through the creation of a popup you can see the popup briefly appear before it is immediately covered by the original calling page.
I've created a sample app that can reproduce the issue: https://github.com/askariya/MauiPopupsApp I originally noticed this while trying Prism Popups (that utilizes Mopups) and I have a project where it happens in Prism as well: https://github.com/askariya/MauiPrismMopupsSampleApp
Steps to Reproduce
- In a ViewModel, add a call to PickAsync() and follow it with a call to open a Popup Dialog:
- var fileData = await FilePicker.PickAsync(); result = await _dialogService.ShowDialogAsync(nameof(PopupNotificationDialog));
- Trigger the above call (ex: with a button press).
- Select a file or back out such that the File Picker closes.
- You will see that the popup does not appear and instead the Page you called from does.
- If you repeat this in debug mode with breakpoints for each step you can see that the Popup does appear but is covered by the calling Page immediately.
Video: https://github.com/LuckyDucko/Mopups/assets/15271126/95ada5ac-e43f-4473-97ee-dd9208b62a8b
- In the video, you can see the Popup appear very briefly, before the main page covers it again.
- Note that I am calling the built-in DualResponseViewModel autogenerated popup, but it happens with any of them.
- At the end of the video, I back out of the hidden popup using the OS back button.
@askariya I faced the same problem with the file picker. Try to add a delay with 100 ms and check this
@Sofiya-kumar Thanks for the suggestion; adding a Task.Delay(100) doesn't seem to work either, though. I think a change will need to be made to the Mopups code to avoid using a workaround like this anyway.
duplicate of https://github.com/LuckyDucko/Mopups/issues/82
#82 is now fixed, but this bug is still occurring. However, the workaround suggested above now works:
var filePath = await FilePicker.PickAsync();
await Task.Delay(100);
await MopupService.Instance.PushAsync(new MyPage(...));