[BUG] Popup crashes on close after changing value on a switch button.
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
- Open included solution and run it.
- Click on button.
- In popup click on switch button.
- Click outside popup.
- 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.
I found a workaround! Removing the switch control in Page unload event will mitigate the issue.
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.