-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement focus traps #6286
Implement focus traps #6286
Conversation
// On mobile platforms, let's not make the keyboard popup unless the dropdown is intentionally searchable. | ||
// Unfortunately it is not enough to just early-return here, | ||
// as even despite that the text box will receive focus via the text box input manager; | ||
// it is necessary to cut off the text box input manager from parent input entirely. | ||
// TODO: preferably figure out a better way to do this. | ||
bool willShowOverlappingKeyboard = host?.OnScreenKeyboardOverlapsGameWindow == true; | ||
|
||
if (willShowOverlappingKeyboard && !AlwaysDisplayOnFocus) | ||
{ | ||
textBoxInputManager.UseParentInput = false; | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't yet tested whether removing this is an issue (likely is). The logic here is quite convoluted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by 5724733. It's touching some scary code but I think it makes sense.
I've added tests in my other PR to ensure the issues linked above are specifically fixed (see cf31661), worth adding in this PR. For ppy/osu#25850, I would just disable searching in |
@frenzibyte Thanks. Added your tests almost verbatim in the last commit. |
Definitely better than the other approach, let's see how this pans out 😄 . |
Fixes ppy/osu#25769
Fixes ppy/osu#26079 (likely)
Supersedes / closes #6095
Closes #6097 (note that ppy/osu#25850 is likely not fixed by this and will need reimplementation)
By extracting focus-management logic out of
InputManager
, we can implement something akin to a focus trap. Components can trap the focus management (ChangeFocus()
/TriggerFocusContention()
) of their subcomponents to add supplementary logic.This PR features a partial redesign of
Dropdown
making use of this. There are two components wanting to manage focus here - theMenu
and theTextBox
.Menu
's focus is trapped byDropdown
and reduced to a no-op.TextBox
's focus is trapped withinDropdownSearchBox
to perform additional functionality such as opening the dropdown on focus, selecting items on commit, clearing text on escape, etc.This is not a breaking change, but I've obsoleted
InputManager.TriggerFocusContention()
andInputManager.ChangeFocus()
partially to make this easy to test.