Repository navigation
test: Verify Button exits Pressed state during async Click handler - #23009
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Uno.UI runtime test to ensure Button exits the Pressed visual state immediately after pointer release, even if the Click handler starts a long-running async operation—addressing the behavior reported in #12028.
Changes:
- Introduce a runtime test that injects mouse press/release and inspects the
CommonStatesvisual state after release. - Validate that
CommonStates.CurrentStateis notPressedwhile the async click handler is still running.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23009/wasm-skia-net9/index.html |
|
|
|
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or it will be closed in 10 days. |
|
This PR was closed because it has been stalled for 10 days with no activity. |
|
Claude finished @MartinZikmund's task in 2m 2s —— View job Code Review
Overall verdict: needs changes before merge. The test intent is correct and the
Cross-cutting note: The Copilot reviewer's suggestion to poll |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23009/wasm-skia-net9/index.html |
…async click Relates to #12028
Addresses the WinAppSDK compile break and the PR review feedback on the When_Button_Does_Not_Stay_Pressed_During_Async_Click_Handler test: - Replace buttonRect.GetCenter() with inline Point math. GetCenter is a Uno.UWP extension (Uno.Extensions.RectExtensions) that is absent on the native WinAppSDK target, which broke the Windows build with CS1061. - Use TrySetResult so a second injected Click can't throw. - Poll for template children and null-check GetVisualStateGroups before querying CommonStates, so the test can't NRE/throw if the template is not ready yet. - Assert the button is in the Pressed state while held, so a button that never engages Pressed fails loudly instead of passing trivially. - Replace the brittle Task.Delay(500) with a gate TaskCompletionSource: the Click handler blocks until the post-release assertion has run, so there is no wall-clock window for the assertion to race. Released in a finally to avoid leaving the handler awaiting forever on failure. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015DYGmMmEsscuswdkmjSNrZ
73954af to
1f1bf0f
Compare
|
Claude finished @MartinZikmund's task in 2m 31s —— View job Code Review
Overall verdict: LGTM. All four issues flagged in the prior review have been resolved in this revision. No new findings.
Cross-cutting checks (all pass):
Validation note (Code review): Assessment is by diff inspection. Runtime validation on Skia Desktop requires |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23009/wasm-skia-net9/index.html |
|
C:/Program Files/Git/azp run |
|
|
Closes #12028
Summary
OutlinedButtonStylefromUno.Materialremains visually "selected" (inPressedvisual state) while a long-running async Click handler (Task.Delay(2000)) is running on Android, iOS, and Windows.CommonStatesgroup transitions out ofPressedimmediately, regardless of the Click handler's async duration.The reported issue appears to be potentially fixed — the test passes on current master (Skia target).
Test(s) added
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Button.cs→When_Button_Does_Not_Stay_Pressed_During_Async_Click_HandlerNotes
The issue was reported on Android, iOS, and Windows, with
Uno.Material'sOutlinedButtonStyle. The runtime test uses the default Button style. If the root cause is in Material's custom visual states or touch-specific pointer capture, the issue may still reproduce on native targets. The test should also be verified on Android/iOS native targets.