diff --git a/src/Files.App.Controls/Omnibar/Omnibar.Events.cs b/src/Files.App.Controls/Omnibar/Omnibar.Events.cs index f33680ad704f..78c4d4c3e271 100644 --- a/src/Files.App.Controls/Omnibar/Omnibar.Events.cs +++ b/src/Files.App.Controls/Omnibar/Omnibar.Events.cs @@ -26,12 +26,13 @@ private void AutoSuggestBox_GettingFocus(UIElement sender, GettingFocusEventArgs private void AutoSuggestBox_LosingFocus(UIElement sender, LosingFocusEventArgs args) { - if (args.NewFocusedElement is Button && IsModeButtonPressed) - { - IsModeButtonPressed = false; - args.TryCancel(); + // Prevent the TextBox from losing focus when the ModeButton is focused + if (args.NewFocusedElement is not Button button || + args.InputDevice is FocusInputDeviceKind.Keyboard || + button.Name.ToString() != "PART_ModeButton") return; - } + + args.TryCancel(); } private void AutoSuggestBox_GotFocus(object sender, RoutedEventArgs e) diff --git a/src/Files.App.Controls/Omnibar/Omnibar.cs b/src/Files.App.Controls/Omnibar/Omnibar.cs index fbe301a3b9df..5806676b5688 100644 --- a/src/Files.App.Controls/Omnibar/Omnibar.cs +++ b/src/Files.App.Controls/Omnibar/Omnibar.cs @@ -33,9 +33,6 @@ public partial class Omnibar : Control private WeakReference _previouslyFocusedElement = new(null); - // NOTE: This is a workaround to keep Omnibar's focus on a mode button being clicked - internal bool IsModeButtonPressed { get; set; } - // Events public event TypedEventHandler? QuerySubmitted; diff --git a/src/Files.App.Controls/Omnibar/Omnibar.xaml b/src/Files.App.Controls/Omnibar/Omnibar.xaml index 546902e4663a..dc84422b9673 100644 --- a/src/Files.App.Controls/Omnibar/Omnibar.xaml +++ b/src/Files.App.Controls/Omnibar/Omnibar.xaml @@ -129,6 +129,7 @@