Skip to content

Code Quality: Use action description when selecting via arrow keys #17227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions src/Files.App/UserControls/NavigationToolbar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,32 +258,38 @@ private void ClickablePath_GettingFocus(UIElement sender, GettingFocusEventArgs

private async void Omnibar_QuerySubmitted(Omnibar sender, OmnibarQuerySubmittedEventArgs args)
{
if (Omnibar.CurrentSelectedMode == OmnibarPathMode)
var mode = Omnibar.CurrentSelectedMode;

// Path mode
if (mode == OmnibarPathMode)
{
await ViewModel.HandleItemNavigationAsync(args.Text);
(MainPageViewModel.SelectedTabItem?.TabItemContent as Control)?.Focus(FocusState.Programmatic);
return;
}
else if (Omnibar.CurrentSelectedMode == OmnibarCommandPaletteMode)

// Command palette mode
else if (mode == OmnibarCommandPaletteMode)
{
if (args.Item is not NavigationBarSuggestionItem item)
return;
var item = args.Item as NavigationBarSuggestionItem;

// Try invoking built-in command
if (item.Text is { } commandText)
foreach (var command in Commands)
{
var command = Commands[commandText];
if (command == Commands.None)
await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidCommand.GetLocalizedResource(),
string.Format(Strings.InvalidCommandContent.GetLocalizedResource(), commandText));
else if (!command.IsExecutable)
await DialogDisplayHelper.ShowDialogAsync(Strings.CommandNotExecutable.GetLocalizedResource(),
string.Format(Strings.CommandNotExecutableContent.GetLocalizedResource(), command.Code));
else
await command.ExecuteAsync();
continue;

if (!string.Equals(command.Description, item?.Text, StringComparison.OrdinalIgnoreCase) &&
!string.Equals(command.Description, args.Text, StringComparison.OrdinalIgnoreCase))
continue;

await command.ExecuteAsync();
(MainPageViewModel.SelectedTabItem?.TabItemContent as Control)?.Focus(FocusState.Programmatic);
return;
}

// Try invoking Windows app action
else if (ActionManager.Instance.ActionRuntime is not null && item.ActionInstance is ActionInstance actionInstance)
if (ActionManager.Instance.ActionRuntime is not null && item?.ActionInstance is ActionInstance actionInstance)
{
// Workaround for https://github.com/microsoft/App-Actions-On-Windows-Samples/issues/7
var action = ActionManager.Instance.ActionRuntime.ActionCatalog.GetAllActions()
Expand All @@ -294,11 +300,20 @@ await DialogDisplayHelper.ShowDialogAsync(Strings.CommandNotExecutable.GetLocali
var overload = action.GetOverloads().FirstOrDefault();
await overload?.InvokeAsync(actionInstance.Context);
}

(MainPageViewModel.SelectedTabItem?.TabItemContent as Control)?.Focus(FocusState.Programmatic);
return;
}

await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidCommand.GetLocalizedResource(),
string.Format(Strings.InvalidCommandContent.GetLocalizedResource(), args.Text));

(MainPageViewModel.SelectedTabItem?.TabItemContent as Control)?.Focus(FocusState.Programmatic);
return;
}
else if (Omnibar.CurrentSelectedMode == OmnibarSearchMode)

// Search mode
else if (mode == OmnibarSearchMode)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1254,15 +1254,15 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
{
ThemedIconStyle = command.Glyph.ToThemedIconStyle(),
Glyph = command.Glyph.BaseGlyph,
Text = command.Code.ToString(),
Text = command.Description,
PrimaryDisplay = command.Description,
HotKeys = command.HotKeys,
SearchText = OmnibarCommandPaletteModeText,
});

foreach (var item in suggestionItems)
{
if (item.Text != Commands.OpenCommandPalette.Code.ToString())
if (item.Text != Commands.OpenCommandPalette.Description.ToString())
OmnibarCommandPaletteModeSuggestionItems.Add(item);
}

Expand Down
Loading