Maui icon indicating copy to clipboard operation
Maui copied to clipboard

[BUG] Popup crashes on close after changing value on a switch button.

Open ne0rrmatrix opened this issue 5 months ago • 2 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

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

  • [x] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug

Current Behavior

If you add a switch to a Content View used as a popup page and then click on switch button to change its value and leave the page it will crash the app. If you do nothing and just close the page it will not crash. Interacting with a switch will crash an app when closing a popup.

Oddly this does not appear to be an issue in Toolkit sample app.

Expected Behavior

If you manipulate a switch it should not cause an app crash when closing a popup.

Steps To Reproduce

  1. Open included solution and run it.
  2. Click on button.
  3. In popup click on switch button.
  4. Click outside popup.
  5. App crashes.

Link to public reproduction project repository

https://github.com/ne0rrmatrix/SimplePopupBug

Environment

- .NET MAUI CommunityToolkit: 12.1.0
- OS: Windows 10 Build 10.0.19041.0
- .NET MAUI: 9.0.90

Anything else?

This issue can be replicated by included code. There are many other ways that you can create a popup that will replicate the behavior. If you do not have a switch or do not click or interact with switch popup behaves as expectedd.

ne0rrmatrix avatar Jul 16 '25 13:07 ne0rrmatrix

I found a workaround! Removing the switch control in Page unload event will mitigate the issue.

ne0rrmatrix avatar Jul 16 '25 15:07 ne0rrmatrix

On Windows, closing the popup while the tab key has focused the switch control causes a crash, regardless of whether the switch control is set to ON or OFF. The only workaround I found is to set the IsEnabled property of all Switch controls to False within the PopupContent's Unloaded event, or to set the PopupContent's IsEnabled property to False. Unfocus was unable to avoid this issue.

cat0363 avatar Sep 19 '25 07:09 cat0363