You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Detached elements can receive or retain keyboard focus #23750
On cross-runtime targets, a UIElement detached from the live visual tree can still pass focusability checks. A stale or deferred Focus() call can move keyboard focus to that detached element, and a focused element removed from the tree can continue holding focus.
Expected behavior 🎯
Only elements in the live visual tree, or freshly attached elements under an active ancestor during Uno's delayed lifecycle activation, should be focusable. Removing a focused subtree should not leave keyboard focus on a detached element.
How to reproduce it (as minimally and precisely as possible) 🔬
Add a focusable element to the window and focus it.
Remove its containing subtree from the visual tree.
Call Focus() on the detached element, or inspect the currently focused element.
Observe that the detached element can receive or retain focus.
The implementation branch includes runtime coverage for detached focus attempts, focus cleanup after removal, and focus-cycle behavior.
Workaround 🛠️
Application code can verify that an element is still loaded and attached before issuing deferred focus requests.
Renderer 🎨
Skia
Native
Affected platforms 📱💻🖥️
Skia cross-runtime targets, including Desktop and WebAssembly.
Uno.Sdk version (and other relevant versions) 📦
Current master.
IDE version 🧑💻
N/A
Anything else we need to know? 💬
WinUI requires an element to be active before it is focusable. Uno needs an ancestor-aware check because child lifecycle activation can occur one tick after attachment.
Activity
test: Exclude tests that never passed on native WASM
test: Exclude tests that never passed on native WASM