Skip to content

Commit abb9011

Browse files
committed
Code Quality: Fixed issue where Omnibar would regain focus together with window
1 parent 4890b48 commit abb9011

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Files.App.Controls/Omnibar/Omnibar.Events.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ private void AutoSuggestBox_LostFocus(object sender, RoutedEventArgs e)
5656

5757
IsFocused = false;
5858
IsFocusedChanged?.Invoke(this, new(IsFocused));
59+
60+
// Workaround to prevent an issue where if the window loses focus and then regains focus,
61+
// the AutoSuggestBox will regain focus and the suggestions popup will open again.
62+
if (element is TextBox)
63+
{
64+
_previouslyFocusedElement.TryGetTarget(out var previouslyFocusedElement);
65+
previouslyFocusedElement?.Focus(FocusState.Programmatic);
66+
}
5967
}
6068

6169
private async void AutoSuggestBox_KeyDown(object sender, KeyRoutedEventArgs e)

0 commit comments

Comments
 (0)