Skip to content
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

Fix mod search box not tracking external changes to focus state #27780

Merged
merged 4 commits into from
Apr 19, 2024

Conversation

mafarrica
Copy link
Contributor

In the Mod selection area, the search bar's focus could be changed by pressing TAB. However, when clicking outside of the search bar, the focus would be killed but two TABs were required to get the focus back on the search bar. This happened because the action of clicking in an empty area would trigger the search bar to change its appearence, but not its internal state. In my solution, I made the OnClick function aware of the search bar's state, so it would not only change its appearance, but also its state. Now, after clicking in an empty area, there is only needed one TAB to select the search box again, as expected.

In the Mod selection area, the search bar's focus could be changed by pressing TAB.
However, when clicking outside of the search bar, the focus would be killed but two TABs were required to get the focus back on the search bar.
This happened because the action of clicking in an empty area would trigger the search bar to change its appearence, but not its internal state.
In my solution, I made the OnClick function aware of the search bar's state, so it would not only change its appearance, but also its state.
Now, after clicking in an empty area, there is only needed one TAB to select the search box again, as expected.
@bdach bdach changed the title Fix #27105: Mod search box doesnt track external focus changes Fix mod search box not tracking external changes to focus state Apr 5, 2024
@@ -953,7 +957,7 @@ protected override bool OnClick(ClickEvent e)
RequestScroll?.Invoke(this);

// Killing focus is done here because it's the only feasible place on ModSelectOverlay you can click on without triggering any action.
Scheduler.Add(() => GetContainingInputManager().ChangeFocus(null));
modSelectOverlayInstance.setTextBoxFocus(false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach is insufficient. It only fixes the bug in the case wherein clicking the columns was specifically what took focus away from the textbox.

If any other component, such as the chat overlay, happens to take away focus, this stops working:

2024-04-05.10-41-36.remuxed.mp4

Note how after opening chat, it takes two tab presses to focus the textbox again.

The actual fix will probably involve looking at the actual focus state of the textbox rather than doing tracking in a separate flag.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Apr 19, 2024
@pull-request-size pull-request-size bot added size/S and removed size/M labels Apr 19, 2024
@bdach
Copy link
Collaborator

bdach commented Apr 19, 2024

I pretty much rewrote this but it's also such a minor change that I'm not going to request a second check, just going to roll forward with it.

@bdach bdach merged commit 1344ca4 into ppy:master Apr 19, 2024
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants