Repository navigation
fix(focus): Prevent detached elements from receiving focus - #23753
Conversation
|
Claude finished @morning4coffe-dev's task in 3m 51s —— View job PR Review: fix(focus): Prevent detached elements from receiving focusTasks:
SummaryVerdict: fix-first — the production code is sound; three test-quality issues need attention before merge. The core approach is correct and well-reasoned. Issues found (2 blocking, 1 minor):
Cross-cutting notes:
|
There was a problem hiding this comment.
Pull request overview
This PR aligns Uno’s cross-runtime focusability checks with WinUI by preventing detached UIElements from being considered focusable, while still allowing same-tick focus for freshly attached elements under an active visual ancestor (to account for Uno’s delayed lifecycle activation).
Changes:
- Gate
UIElement.IsFocusable(andTextBlock/Hyperlinkfocusability) on a new cross-runtime “active or attached under active ancestor” predicate. - Add a helper (
IsActiveOrAttachedUnderActiveAncestor) to detect “effectively active” elements during the activation gap. - Add runtime tests covering focus attempts and focus-candidate searches on detached subtrees.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.UI/UI/Xaml/UIElement.FocusMixins.cs | Adds cross-runtime active/ancestor gating to IsFocusable and introduces IsActiveOrAttachedUnderActiveAncestor(). |
| src/Uno.UI/UI/Xaml/Documents/Hyperlink.mux.cs | Applies the new active/ancestor gating to hyperlink focusability (cross-runtime only). |
| src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.cs | Applies the new active/ancestor gating to TextBlock.IsFocusable (cross-runtime only). |
| src/Uno.UI/UI/Xaml/Controls/Popup/Popup.h.mux.cs | Documents why Popup.IsFocusable intentionally does not use an active-tree check. |
| src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Input/Given_FocusManager_DetachedElements.cs | Adds runtime coverage for detached focus attempts and focus-candidate search behavior on detached subtrees. |
💡 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-23753/wasm-skia-net9/index.html |
|
|
b8ec37b to
901530b
Compare
|
Claude finished @morning4coffe-dev's task in 9m 13s —— View job PR Review: fix(focus): Prevent detached elements from receiving focusTasks:
SummaryVerdict: fix-first — 3 blocking WASM compile errors in Root cause of CI failure ( On WASM,
The fix is Everything else looks correct:
|
- Guard InlineCollection focus-clearing with #if !__WASM__ so the WASM build compiles (_collection is UIElementCollection there, not DependencyObjectCollection<Inline>); WASM already clears focus for a removed inline via the live Leave walk. - Attach the XYFocus tree-walker and bubbling test trees to a live window so their elements are active and thus focusable under the new IsFocusable rule (detached elements are no longer focus candidates). - Gate the Uno-specific LosingFocus mechanics assertions under HAS_UNO; the parity outcome (focus leaves the removed element) is kept for all platforms, so native WinUI mirrors the passing sibling test. Co-authored-by: Copilot <[email protected]> Copilot-Session: eef860b5-08dd-4c8c-9633-9dd4bed7a23e
|
Claude finished @morning4coffe-dev's task in 6m 56s —— View job PR Review: fix(focus): Prevent detached elements from receiving focusTasks:
SummaryVerdict: ship — all blocking issues from prior rounds are resolved; no new blocking findings. Confirmed fixes in this round: The three WASM compile errors in Other items are also clean:
One minor pre-existing note (outside scope, no action needed): |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23753/wasm-skia-net9/index.html |
Co-authored-by: Copilot <[email protected]> Copilot-Session: 8d4ade86-b17e-4af4-a8b2-4d6a41328960
|
Claude finished @morning4coffe-dev's task in 6m 25s —— View job PR Review: fix(focus): Prevent detached elements from receiving focusTasks:
SummaryVerdict: ship — no new issues found in this round; all prior blocking findings are resolved. What was verified in this pass:
Test file ( |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23753/wasm-skia-net9/index.html |
GitHub Issue: closes #23750
PR Type:
🐞 Bugfix
What changed? 🚀
PR Checklist ✅
Screenshots Compare Test Runresults.