Skip to content

Commit a3b91eb

Browse files
authored
Fix: Fixed issue that caused shortcut keys to be displayed incorrectly in the command palette (#15271)
1 parent 22553a5 commit a3b91eb

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using CommunityToolkit.WinUI.UI;
5-
using Microsoft.UI.Input;
6-
using Microsoft.UI.Xaml;
7-
using Microsoft.UI.Xaml.Automation;
8-
using Microsoft.UI.Xaml.Automation.Peers;
94
using Microsoft.UI.Xaml.Controls;
10-
using Microsoft.UI.Xaml.Controls.Primitives;
115

126
namespace Files.App.UserControls.KeyboardShortcut
137
{
@@ -28,10 +22,24 @@ private void OnSizeChanged()
2822
{
2923
}
3024

31-
private void OnHotKeysChanged()
25+
private async void OnHotKeysChanged()
3226
{
27+
var keyboardShortcutItemsControl = GetTemplateChild(KeyboardShortcutItemsControl) as ItemsControl;
28+
for (int i = 0; i < 100 && keyboardShortcutItemsControl is null; i++)
29+
{
30+
// Wait for KeyboardShortcutItemsControl to be loaded
31+
await Task.Delay(10);
32+
keyboardShortcutItemsControl = GetTemplateChild(KeyboardShortcutItemsControl) as ItemsControl;
33+
}
34+
35+
if (keyboardShortcutItemsControl is null)
36+
return;
37+
3338
if (HotKeys.IsEmpty)
39+
{
40+
keyboardShortcutItemsControl.ItemsSource = null;
3441
return;
42+
}
3543

3644
List<KeyboardShortcutItem> items = [];
3745

@@ -94,10 +102,7 @@ void GetModifierCode(KeyModifiers modifier)
94102
}
95103

96104
// Set value
97-
if (GetTemplateChild(KeyboardShortcutItemsControl) is ItemsControl keyboardShortcutItemsControl)
98-
{
99-
keyboardShortcutItemsControl.ItemsSource = items;
100-
}
105+
keyboardShortcutItemsControl.ItemsSource = items;
101106
}
102107
}
103108
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,10 @@ public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPag
946946
for (int index = 0; index < suggestions.Count; index++)
947947
{
948948
if (NavigationBarSuggestions.Count > index && NavigationBarSuggestions[index].PrimaryDisplay == suggestions[index].PrimaryDisplay)
949+
{
949950
NavigationBarSuggestions[index].SearchText = suggestions[index].SearchText;
951+
NavigationBarSuggestions[index].HotKeys = suggestions[index].HotKeys;
952+
}
950953
else
951954
NavigationBarSuggestions.Insert(index, suggestions[index]);
952955
}

0 commit comments

Comments
 (0)