Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
11 changes: 10 additions & 1 deletion src/Files.App.Controls/Omnibar/Omnibar.Events.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

using Microsoft.UI.Input;
using Microsoft.UI.Xaml.Input;
using Windows.System;
using Windows.UI.Core;

namespace Files.App.Controls
{
Expand Down Expand Up @@ -47,7 +49,7 @@ private void AutoSuggestBox_LostFocus(object sender, RoutedEventArgs e)
IsFocused = false;
}

private void AutoSuggestBox_KeyDown(object sender, KeyRoutedEventArgs e)
private async void AutoSuggestBox_KeyDown(object sender, KeyRoutedEventArgs e)
{
if (e.Key is VirtualKey.Enter)
{
Expand Down Expand Up @@ -98,6 +100,13 @@ private void AutoSuggestBox_KeyDown(object sender, KeyRoutedEventArgs e)
previouslyFocusedElement?.Focus(FocusState.Programmatic);
}
}
else if (e.Key == VirtualKey.Tab && !InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down))
{
e.Handled = true;
IsFocused = false;
await Task.Delay(15);
CurrentSelectedMode?.ContentOnInactive?.Focus(FocusState.Keyboard);
}
else
{
_textChangeReason = OmnibarTextChangeReason.UserInput;
Expand Down
43 changes: 25 additions & 18 deletions src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the brief summary of this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a try catch when loading actions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

Original file line number Diff line number Diff line change
Expand Up @@ -1209,31 +1209,38 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()

dispatcherQueue.TryEnqueue(() =>
{
var selectedItemPath = ContentPageContext.SelectedItem.ItemPath;
var fileActionEntity = ActionManager.Instance.EntityFactory.CreateFileEntity(selectedItemPath);
var actions = ActionManager.Instance.ActionRuntime.ActionCatalog.GetActionsForInputs(new[] { fileActionEntity });

foreach (var action in actions.Where(a => a.Definition.Description.Contains(OmnibarCommandPaletteModeText, StringComparison.OrdinalIgnoreCase)))
try
{
var newItem = new NavigationBarSuggestionItem
{
PrimaryDisplay = action.Definition.Description,
SearchText = OmnibarCommandPaletteModeText,
ActionInstance = action
};
var selectedItemPath = ContentPageContext.SelectedItem.ItemPath;
var fileActionEntity = ActionManager.Instance.EntityFactory.CreateFileEntity(selectedItemPath);
var actions = ActionManager.Instance.ActionRuntime.ActionCatalog.GetActionsForInputs(new[] { fileActionEntity });

if (Uri.TryCreate(action.Definition.IconFullPath, UriKind.RelativeOrAbsolute, out Uri? validUri))
foreach (var action in actions.Where(a => a.Definition.Description.Contains(OmnibarCommandPaletteModeText, StringComparison.OrdinalIgnoreCase)))
{
try
var newItem = new NavigationBarSuggestionItem
{
newItem.ActionIconSource = new BitmapImage(validUri);
}
catch (Exception)
PrimaryDisplay = action.Definition.Description,
SearchText = OmnibarCommandPaletteModeText,
ActionInstance = action
};

if (Uri.TryCreate(action.Definition.IconFullPath, UriKind.RelativeOrAbsolute, out Uri? validUri))
{
try
{
newItem.ActionIconSource = new BitmapImage(validUri);
}
catch (Exception)
{
}
}
}

OmnibarCommandPaletteModeSuggestionItems.Add(newItem);
OmnibarCommandPaletteModeSuggestionItems.Add(newItem);
}
}
catch (Exception ex)
{
App.Logger.LogWarning(ex, ex.Message);
}
});
}
Expand Down
Loading