Skip to content

Commit 51db72c

Browse files
committed
Code Quality: Fixed Command Palette text when switching between modes
1 parent bd2f5f1 commit 51db72c

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ private void Omnibar_SizeChanged(object sender, SizeChangedEventArgs e)
1515
// Popup width has to be set manually because it doesn't stretch with the parent
1616
_textBoxSuggestionsContainerBorder.Width = ActualWidth;
1717
}
18+
19+
private void Omnibar_LostFocus(object sender, RoutedEventArgs e)
20+
{
21+
// Reset to the default mode when Omnibar loses focus
22+
CurrentSelectedMode = Modes?.FirstOrDefault();
23+
}
1824

1925
private void AutoSuggestBox_GettingFocus(UIElement sender, GettingFocusEventArgs args)
2026
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ protected override void OnApplyTemplate()
7575
PopulateModes();
7676

7777
SizeChanged += Omnibar_SizeChanged;
78+
LostFocus += Omnibar_LostFocus;
7879
_textBox.GettingFocus += AutoSuggestBox_GettingFocus;
7980
_textBox.GotFocus += AutoSuggestBox_GotFocus;
8081
_textBox.LosingFocus += AutoSuggestBox_LosingFocus;

src/Files.App/UserControls/NavigationToolbar.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@
351351
x:Load="{x:Bind ViewModel.EnableOmnibar, Mode=OneWay}"
352352
CurrentSelectedModeName="{x:Bind ViewModel.OmnibarCurrentSelectedModeName, Mode=TwoWay}"
353353
IsFocused="{x:Bind ViewModel.IsOmnibarFocused, Mode=TwoWay}"
354-
LostFocus="Omnibar_LostFocus"
354+
ModeChanged="Omnibar_ModeChanged"
355355
PreviewKeyDown="Omnibar_PreviewKeyDown"
356356
QuerySubmitted="Omnibar_QuerySubmitted"
357357
TextChanged="Omnibar_TextChanged">

src/Files.App/UserControls/NavigationToolbar.xaml.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,11 @@ private void BreadcrumbBar_ItemDropDownFlyoutClosed(object sender, BreadcrumbBar
427427
e.Flyout.Items.Clear();
428428
}
429429

430-
private void Omnibar_LostFocus(object sender, RoutedEventArgs e)
430+
private void Omnibar_ModeChanged(object sender, OmnibarModeChangedEventArgs e)
431431
{
432+
// Reset the command palette text when switching modes
432433
if (Omnibar.CurrentSelectedMode == OmnibarCommandPaletteMode)
433-
{
434-
Omnibar.CurrentSelectedMode = OmnibarPathMode;
435434
ViewModel.OmnibarCommandPaletteModeText = string.Empty;
436-
}
437435
}
438436

439437
private void Omnibar_PreviewKeyDown(object sender, KeyRoutedEventArgs e)

0 commit comments

Comments
 (0)