Skip to content

Commit

Permalink
Merge pull request #6353 from smoogipoo/dropdown-empty-search-click
Browse files Browse the repository at this point in the history
Allow clicking on empty search header to close dropdown
  • Loading branch information
peppy authored Aug 9, 2024
2 parents 3dc9db5 + dd6ad92 commit 8e2a7e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ public void TestPaddedSearchBar()
}

[Test]
public void TestDoubleClickOnHeader()
public void TestDoubleClickOnHeader([Values] bool alwaysShowSearchBar)
{
TestDropdown testDropdown = null!;
bool wasOpened = false;
Expand All @@ -747,6 +747,8 @@ public void TestDoubleClickOnHeader()
wasClosed = false;
testDropdown = createDropdown();
testDropdown.AlwaysShowSearchBar = alwaysShowSearchBar;
testDropdown.Menu.StateChanged += s =>
{
wasOpened |= s == MenuState.Open;
Expand Down
4 changes: 2 additions & 2 deletions osu.Framework/Graphics/UserInterface/DropdownHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ private void updateState()
/// </summary>
private bool onClick(ClickEvent e)
{
// Allow input to fall through to the search bar (and its contained textbox) if it's visible.
if (SearchBar.State.Value == Visibility.Visible)
// Allow input to fall through to the search bar (and its contained textbox) if there's any search text.
if (SearchBar.State.Value == Visibility.Visible && !string.IsNullOrEmpty(SearchTerm.Value))
return false;

// Otherwise, the header acts as a button to show/hide the menu.
Expand Down
2 changes: 2 additions & 0 deletions osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ private void onMenuStateChanged(MenuState state)
}
else
dropdown.ChangeFocus(textBox);

updateTextBoxVisibility();
}

/// <summary>
Expand Down

0 comments on commit 8e2a7e6

Please sign in to comment.