Removing the focused element from the visual tree will not move focus to the "next focusable element", but to the first focusable element from root. #15942
Labels
area/focus
Categorizes an issue as relevant to focus management
difficulty/starter 🚀
Categorizes an issue for which the difficulty level is reachable by newcomers
kind/bug
Something isn't working
platform/all
Categorizes an issue or PR as relevant to the all platforms
Current behavior
This is because the element is removed from the tree before the element is
Unloaded
. On unloading, we callSetFocusOnNextFocusableElement
, which callsGetNextTabStop
.GetNextTabStop
won't find any tab stops because the element is already removed from the visual tree. We will then fallback to the first focusable element in the tree, which is incorrect.Expected behavior
No response
How to reproduce it (as minimally and precisely as possible)
Focus
btn1
then remove it from the tree (I did this with a KeyDown callback onbtn1
). You should see the next focusable element (btn2) focused, but in Uno, this will cause the first focusable element from root to be focused.Interestingly, in this repro, WinUI does something weird. It actually focuses
btn3
instead ofbtn2
.Workaround
No response
Works on UWP/WinUI
None
Environment
No response
NuGet package version(s)
No response
Affected platforms
No response
IDE
No response
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
No response
The text was updated successfully, but these errors were encountered: