Maui icon indicating copy to clipboard operation
Maui copied to clipboard

[BUG] VisualState not updating properly when closing a popup from Popup V2

Open gchapeaux opened this issue 3 months ago • 3 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

To simplify, picture a simple popup (with the popup V2 implementation) with a single button in it, used to close the popup. When running my app on Windows and opening the popup, the popup seem to work just fine. However, when closing the popup, and re-opening it, the button appears to be stuck in the "Pressed" VisualState. Clicking on it then calls the command as expected, but the button doesn't have the correct appearance.

A Gif video showing the issue :

Image

Expected Behavior

When reopening the popup, the button should be using the "Normal" VisualState instead of "Pressed".

Steps To Reproduce

  1. Open and run the solution from the reproduction repository
  2. Open the popup, and close it by clicking on the "Close" button
  3. Open the popup again : the button uses the wrong VisualState. (4. There is actually a trick to "reset" the button : click and hold on the button, then get the mouse pointer out of the clickable zone. Somehow it resets it.)

Link to public reproduction project repository

https://github.com/gchapeaux/Sandbox_Popup

Environment

- .NET MAUI CommunityToolkit: 12.2.0
- OS: Windows 11 Professionnal
- .NET MAUI: Maui 9.0

Anything else?

I tried an unsuccessful workaround, but still worth sharing : I wanted to manually update the button's VisualState through its OnClicked event. However, with this tentative, the button appears at first in the correct VisualState, but once mouseovered it goes back to the "Pressed" state.

EDIT : a workaround suggested by @bijington : declare the popup as Transient instead of Singleton

gchapeaux avatar Oct 08 '25 19:10 gchapeaux

You might be able to workaround this by registering the popup as transient rather than singleton

bijington avatar Oct 08 '25 19:10 bijington

there are similar issues when you press a button logged against the maui repo, with the button being left at the wrong state:

see https://github.com/dotnet/maui/issues/18958 and https://github.com/dotnet/maui/issues/30958

so there is a possibility this isn't a toolkit issue but a maui issue instead.

MitchBomcanhao avatar Oct 20 '25 07:10 MitchBomcanhao

I’m not sure if this is a related issue, but I created a custom button with a Windows-specific behavior to display a hand cursor on hover. It doesn’t work, the cursor never changes, as if the behavior isn’t being applied. It does work on a normal page. I also registered the popups as transient.

malsabi avatar Oct 22 '25 07:10 malsabi