Refactor dropdown search bar and fix many issues with it#6097
Refactor dropdown search bar and fix many issues with it#6097frenzibyte wants to merge 8 commits intoppy:masterfrom
Conversation
| // On mobile platforms, let's not make the keyboard popup unless the dropdown is intentionally searchable. | ||
| // todo: however, this causes such dropdowns to not be searchable at all when using hardware keyboard on mobile. | ||
| if (host.OnScreenKeyboardOverlapsGameWindow && !AlwaysDisplayOnFocus) | ||
| return Array.Empty<Drawable>(); |
There was a problem hiding this comment.
The change in #6080 has been moved here. Once a dropdown is focused, if AlwaysDisplayOnFocus is false and the platform shows a software keyboard, then the TextBox is excluded from being focused, therefore not showing any software keyboard when the dropdown is open.
0c023e4 to
5f2acdd
Compare
|
@frenzibyte I don't suppose you ever made test coverage of the actual issues this is fixing (ie the issues being closed by this PR)? I'd like to give this a shot from scratch because I can't really get behind the multiple focus path that you've proposed here. |
|
Sorry about that, I've included test coverage for ppy/osu#25769 and ppy/osu#26079, which are the issues fixed by the "multiple focus target" approach. Should be good enough to explore alternative options with. I've also pushed a separate branch for the tests in case needed: master...frenzibyte:osu-framework:dropdown-search-bar-issues |
Using the concept of "multiple focus targets", now
Dropdowngains focus when in an open state, and in addition sends focus events toMenuand indirectly to the search bar text box using the chain "DropdownHeader->DropdownSearchBar->TextBox".This eliminates the necessity of an input manager inside
DropdownSearchBar, which in turn resolves many issues that arose from it (such as blocking key events from propagating past the search bar text box, or the search bar text box receiving focus despite being blocked by another component in front of it).A necessary component in this implementation is to stop both
MenuandTextBoxfrom managing the focus state completely, using an internal boolean property. I'm not quite fond of the approach, but I did not want to overthink this more than I had done already (one idea I had that I scraped off was defining anIUIControlinterface, and letMenu/TextBoxavoid handling focus if there's a parent with theIUIControlinterface, via DI or parent traversal).As a side detail in this change, positional input on the search bar is now possible (i.e. you can drag the search bar text box to change selection).