Skip to content

Commit 84ad3aa

Browse files
committed
Fixed an issue
1 parent d27b396 commit 84ad3aa

File tree

3 files changed

+42
-36
lines changed

3 files changed

+42
-36
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,10 @@ partial void OnCurrentSelectedModeChanged(OmnibarMode? newValue)
2626
{
2727
CurrentSelectedModeName = newValue?.ModeName;
2828
}
29+
30+
partial void OnIsFocusedChanged(bool newValue)
31+
{
32+
//_textBox?.Focus(newValue ? FocusState.Programmatic : FocusState.Unfocused);
33+
}
2934
}
3035
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,9 @@ private async void Omnibar_QuerySubmitted(Omnibar sender, OmnibarQuerySubmittedE
261261

262262
private async void Omnibar_SuggestionChosen(Omnibar sender, OmnibarSuggestionChosenEventArgs args)
263263
{
264-
if (args.SelectedItem is OmnibarPathModeSuggestionModel item)
265-
await ViewModel.HandleFolderNavigationAsync(item.Path);
264+
if (args.SelectedItem is OmnibarPathModeSuggestionModel item &&
265+
!string.IsNullOrEmpty(item.Path))
266+
await ViewModel.HandleItemNavigationAsync(item.Path);
266267
}
267268

268269
private async void Omnibar_TextChanged(Omnibar sender, OmnibarTextChangedEventArgs args)
@@ -274,7 +275,7 @@ private async void BreadcrumbBar_ItemClicked(Controls.BreadcrumbBar sender, Cont
274275
{
275276
if (args.IsRootItem)
276277
{
277-
// TODO: Go to Home
278+
await ViewModel.HandleItemNavigationAsync("Home");
278279
return;
279280
}
280281

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

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,48 +1068,48 @@ public async Task PopulateOmnibarSuggestionsForPathMode()
10681068
newSuggestions.AddRange(currPath.Select(x => new OmnibarPathModeSuggestionModel(x.Path, x.Item.DisplayName)));
10691069
newSuggestions.AddRange(subPath.Select(x => new OmnibarPathModeSuggestionModel(x.Path, PathNormalization.Combine(currPath.First().Item.DisplayName, x.Item.DisplayName))));
10701070
}
1071+
}
10711072

1072-
// If there are no suggestions, show "No suggestions"
1073-
if (newSuggestions.Count is 0)
1074-
{
1075-
AddNoResultsItem();
1076-
}
1073+
// If there are no suggestions, show "No suggestions"
1074+
if (newSuggestions.Count is 0)
1075+
{
1076+
AddNoResultsItem();
1077+
}
10771078

1078-
// Check whether at least one item is in common between the old and the new suggestions
1079-
// since Omnibar suggestions popup becoming empty causes flickering
1080-
if (!PathModeSuggestionItems.IntersectBy(newSuggestions, x => x.DisplayName).Any())
1079+
// Check whether at least one item is in common between the old and the new suggestions
1080+
// since the suggestions popup becoming empty causes flickering
1081+
if (!PathModeSuggestionItems.IntersectBy(newSuggestions, x => x.DisplayName).Any())
1082+
{
1083+
// No items in common, update the list in-place
1084+
for (int index = 0; index < newSuggestions.Count; index++)
10811085
{
1082-
// No items in common, update the list in-place
1083-
for (int index = 0; index < newSuggestions.Count; index++)
1086+
if (index < PathModeSuggestionItems.Count)
10841087
{
1085-
if (index < PathModeSuggestionItems.Count)
1086-
{
1087-
PathModeSuggestionItems[index] = newSuggestions[index];
1088-
}
1089-
else
1090-
{
1091-
PathModeSuggestionItems.Add(newSuggestions[index]);
1092-
}
1088+
PathModeSuggestionItems[index] = newSuggestions[index];
1089+
}
1090+
else
1091+
{
1092+
PathModeSuggestionItems.Add(newSuggestions[index]);
10931093
}
1094-
1095-
while (PathModeSuggestionItems.Count > newSuggestions.Count)
1096-
PathModeSuggestionItems.RemoveAt(PathModeSuggestionItems.Count - 1);
10971094
}
1098-
else
1099-
{
1100-
// At least an element in common, show animation
1101-
foreach (var s in PathModeSuggestionItems.ExceptBy(newSuggestions, x => x.DisplayName).ToList())
1102-
PathModeSuggestionItems.Remove(s);
11031095

1104-
for (int index = 0; index < newSuggestions.Count; index++)
1096+
while (PathModeSuggestionItems.Count > newSuggestions.Count)
1097+
PathModeSuggestionItems.RemoveAt(PathModeSuggestionItems.Count - 1);
1098+
}
1099+
else
1100+
{
1101+
// At least an element in common, show animation
1102+
foreach (var s in PathModeSuggestionItems.ExceptBy(newSuggestions, x => x.DisplayName).ToList())
1103+
PathModeSuggestionItems.Remove(s);
1104+
1105+
for (int index = 0; index < newSuggestions.Count; index++)
1106+
{
1107+
if (PathModeSuggestionItems.Count > index && PathModeSuggestionItems[index].DisplayName == newSuggestions[index].DisplayName)
11051108
{
1106-
if (PathModeSuggestionItems.Count > index && PathModeSuggestionItems[index].DisplayName == newSuggestions[index].DisplayName)
1107-
{
1108-
PathModeSuggestionItems[index] = newSuggestions[index];
1109-
}
1110-
else
1111-
PathModeSuggestionItems.Insert(index, newSuggestions[index]);
1109+
PathModeSuggestionItems[index] = newSuggestions[index];
11121110
}
1111+
else
1112+
PathModeSuggestionItems.Insert(index, newSuggestions[index]);
11131113
}
11141114
}
11151115

0 commit comments

Comments
 (0)