Skip to content

Commit 89be2ba

Browse files
committed
Update
1 parent 2df25f2 commit 89be2ba

File tree

3 files changed

+25
-35
lines changed

3 files changed

+25
-35
lines changed

src/Files.App/UserControls/NavigationToolbar.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@
322322
Grid.Column="1"
323323
x:Load="{x:Bind ViewModel.EnableOmnibar, Mode=OneWay}"
324324
CurrentSelectedModeName="{x:Bind ViewModel.OmnibarCurrentSelectedModeName, Mode=TwoWay}"
325-
IsFocused="{x:Bind ViewModel.IsOmnibarFocused, Mode=TwoWay}"
325+
GotFocus="Omnibar_GotFocus"
326326
LostFocus="Omnibar_LostFocus"
327327
PreviewKeyDown="Omnibar_PreviewKeyDown"
328328
QuerySubmitted="Omnibar_QuerySubmitted"

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public sealed partial class NavigationToolbar : UserControl
2323
private readonly MainPageViewModel MainPageViewModel = Ioc.Default.GetRequiredService<MainPageViewModel>();
2424
private readonly ICommandManager Commands = Ioc.Default.GetRequiredService<ICommandManager>();
2525
private readonly StatusCenterViewModel OngoingTasksViewModel = Ioc.Default.GetRequiredService<StatusCenterViewModel>();
26+
private readonly IContentPageContext ContentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();
2627

2728
// Properties
2829

@@ -411,6 +412,27 @@ private void BreadcrumbBar_ItemDropDownFlyoutClosed(object sender, BreadcrumbBar
411412
e.Flyout.Items.Clear();
412413
}
413414

415+
private async void Omnibar_GotFocus(object sender, RoutedEventArgs e)
416+
{
417+
switch (ViewModel.OmnibarCurrentSelectedModeName)
418+
{
419+
case NavigationToolbarViewModel.OmnibarPathModeName:
420+
ViewModel.PathText =
421+
string.IsNullOrEmpty(ContentPageContext.ShellPage?.ShellViewModel?.WorkingDirectory)
422+
? Constants.UserEnvironmentPaths.HomePath
423+
: ContentPageContext.ShellPage.ShellViewModel.WorkingDirectory;
424+
await ViewModel.PopulateOmnibarSuggestionsForPathMode();
425+
break;
426+
case NavigationToolbarViewModel.OmnibarPaletteModeName:
427+
ViewModel.PopulateOmnibarSuggestionsForCommandPaletteMode();
428+
break;
429+
case NavigationToolbarViewModel.OmnibarSearchModeName:
430+
break;
431+
default:
432+
break;
433+
}
434+
}
435+
414436
private void Omnibar_LostFocus(object sender, RoutedEventArgs e)
415437
{
416438
if (Omnibar.CurrentSelectedMode == OmnibarCommandPaletteMode)

src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -230,39 +230,6 @@ public string? PathText
230230
private string? _OmnibarCommandPaletteModeText;
231231
public string? OmnibarCommandPaletteModeText { get => _OmnibarCommandPaletteModeText; set => SetProperty(ref _OmnibarCommandPaletteModeText, value); }
232232

233-
private bool _IsOmnibarFocused;
234-
public bool IsOmnibarFocused
235-
{
236-
get => _IsOmnibarFocused;
237-
set
238-
{
239-
// NOTE: Don't call ObservableObject.SetProperty() here since we don't want to change focus logic outside of the control.
240-
241-
_IsOmnibarFocused = value;
242-
243-
if (value)
244-
{
245-
switch (OmnibarCurrentSelectedModeName)
246-
{
247-
case OmnibarPathModeName:
248-
PathText =
249-
string.IsNullOrEmpty(ContentPageContext.ShellPage?.ShellViewModel?.WorkingDirectory)
250-
? Constants.UserEnvironmentPaths.HomePath
251-
: ContentPageContext.ShellPage.ShellViewModel.WorkingDirectory;
252-
_ = PopulateOmnibarSuggestionsForPathMode();
253-
break;
254-
case OmnibarPaletteModeName:
255-
PopulateOmnibarSuggestionsForCommandPaletteMode();
256-
break;
257-
case OmnibarSearchModeName:
258-
break;
259-
default:
260-
break;
261-
}
262-
}
263-
}
264-
}
265-
266233
private string _OmnibarCurrentSelectedModeName = OmnibarPathModeName;
267234
public string OmnibarCurrentSelectedModeName { get => _OmnibarCurrentSelectedModeName; set => SetProperty(ref _OmnibarCurrentSelectedModeName, value); }
268235

@@ -735,7 +702,6 @@ await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidItemDialogTitle.GetLoca
735702
}
736703

737704
PathControlDisplayText = ContentPageContext.ShellPage.ShellViewModel.WorkingDirectory;
738-
IsOmnibarFocused = false;
739705
}
740706

741707
public void PathBoxItem_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
@@ -1074,6 +1040,8 @@ private static async Task<bool> LaunchApplicationFromPath(string currentInput, s
10741040

10751041
public async Task PopulateOmnibarSuggestionsForPathMode()
10761042
{
1043+
PathModeSuggestionItems.Clear();
1044+
10771045
var result = await SafetyExtensions.IgnoreExceptions((Func<Task<bool>>)(async () =>
10781046
{
10791047
List<OmnibarPathModeSuggestionModel>? newSuggestions = [];

0 commit comments

Comments
 (0)