Skip to content

[BUG] Popup v2 - App Crash with secondary Window #2700

Closed

Description

@hwsmo

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

The new popup implementation released with version 12.0.0 doesn't work in a Windows Shell app and secondary windows. If I open a page in a new window and then try to open a popup, the app crashes.

The reason is that access to the current shell instance is done with Shell.Current in the PopupPage constructor. However, since the shell window is not active because the secondary window is active, this leads to the following exception:

throw new InvalidOperationException($"Unable to determine the current Shell instance you want to use. Please access Shell via the Windows property on {Application.Current.GetType()}.");

Expected Behavior

The popup will appear in the secondary window.

Steps To Reproduce

The new popup implementation released with version 12.0.0 doesn't work in a Windows Shell app and secondary windows. If I open a page in a new window and then try to open a popup, the app crashes.

Link to public reproduction project repository

Not required as it is very easy to adjust

Environment

- .NET MAUI CommunityToolkit: 12.0.0
- OS: Windows 11
- .NET MAUI: 9.0.70

Anything else?

No response

Activity

  1. VladislavAntonyuk commented on Jun 11, 2025

    @VladislavAntonyuk
    Contributor

    In that case, we allow you to use INavigation. It is not necessary to be a Shell.

  2. dotnet-policy-service commented on Jun 11, 2025

    @dotnet-policy-service
    Contributor

    Hi @@hwsmo! We have added the needs reproduction label to this issue, which indicates that we are unable to take further action until you provide a reproduction sample that we can use to reproduce + fix your bug. In accordance with the Reporting a bug section of our Contributing.md that you confirmed reading before you submitted this Issue, we ask that every Issue author provide a link to an open-source repository containing the reproduction sample app. This issue will be closed automatically in 5 days if we do not receive a reproduction sample from you. Please feel free to re-open this Issue once you have provided a reproduction sample.

  3. hwsmo commented on Jun 11, 2025

    @hwsmo
    Author

    @VladislavAntonyuk Unfortunately, this is not the solution, because even then an instance of PopUpPage is created:

    Image

    and the current shell instance is accessed via Shell.Current:

    Image

    if (Shell.Current is Shell shell)

    However, accessing Shell.Current requires that the shell window is "Active":

    Image

    And that is exactly what leads to the exception and the app crash.

  4. bijington commented on Jun 11, 2025

    @bijington
    Contributor

    Do we need to call SetPresentationMode on shell when we call it at the end of the constructor on this?

  5. hwsmo commented on Jun 11, 2025

    @hwsmo
    Author

    @bijington That's right, Shell.SetPresentationMode() is called again at the end. Maybe that would be the solution. Anyway, I would be happy, because my Popup v2 migration is done, but unfortunately this is currently the show stopper.

  6. dotnet-policy-service commented on Jun 16, 2025

    @dotnet-policy-service
    Contributor

    This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 3 days. It will be closed if no further activity occurs within 2 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

  7. TheCodeTraveler commented on Jun 16, 2025

    @TheCodeTraveler
    Collaborator

    Fixed in #2716

  8. locked and limited conversation to collaborators on Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions