From 751b5a58cd12265bd07038e3e1082ee84c7ba34a Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 9 Aug 2024 18:41:42 +0900 Subject: [PATCH 1/3] Immediately update textbox visibility on state change --- osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs b/osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs index b3950bf345..c0879d6ac5 100644 --- a/osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs +++ b/osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs @@ -150,6 +150,8 @@ private void onMenuStateChanged(MenuState state) } else dropdown.ChangeFocus(textBox); + + updateTextBoxVisibility(); } /// From 6478b8989ab7e654a5cba495b1f5f57b2c6ce1a9 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 9 Aug 2024 18:41:45 +0900 Subject: [PATCH 2/3] Add failing test --- osu.Framework.Tests/Visual/UserInterface/TestSceneDropdown.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Framework.Tests/Visual/UserInterface/TestSceneDropdown.cs b/osu.Framework.Tests/Visual/UserInterface/TestSceneDropdown.cs index a3dab1f478..c1d247b409 100644 --- a/osu.Framework.Tests/Visual/UserInterface/TestSceneDropdown.cs +++ b/osu.Framework.Tests/Visual/UserInterface/TestSceneDropdown.cs @@ -735,7 +735,7 @@ public void TestPaddedSearchBar() } [Test] - public void TestDoubleClickOnHeader() + public void TestDoubleClickOnHeader([Values] bool alwaysShowSearchBar) { TestDropdown testDropdown = null!; bool wasOpened = false; @@ -747,6 +747,8 @@ public void TestDoubleClickOnHeader() wasClosed = false; testDropdown = createDropdown(); + testDropdown.AlwaysShowSearchBar = alwaysShowSearchBar; + testDropdown.Menu.StateChanged += s => { wasOpened |= s == MenuState.Open; From dd6ad923d12f83f8428ef7e177134f6f7f56e133 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 9 Aug 2024 18:42:51 +0900 Subject: [PATCH 3/3] Allow clicking on empty search header to close dropdown --- osu.Framework/Graphics/UserInterface/DropdownHeader.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Framework/Graphics/UserInterface/DropdownHeader.cs b/osu.Framework/Graphics/UserInterface/DropdownHeader.cs index 2cf59c3cc9..433a0e349e 100644 --- a/osu.Framework/Graphics/UserInterface/DropdownHeader.cs +++ b/osu.Framework/Graphics/UserInterface/DropdownHeader.cs @@ -139,8 +139,8 @@ private void updateState() /// 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.