Skip to content
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

Fix: Fixed issue where the path bar didn't display the query when searching #14541

Merged
merged 1 commit into from
Jan 24, 2024
Merged
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
15 changes: 15 additions & 0 deletions src/Files.App/Views/Shells/BaseShellPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,20 +459,35 @@ protected async void DrivesManager_PropertyChanged(object sender, PropertyChange
await DisplayFilesystemConsentDialogAsync();
}

private TaskCompletionSource? _getDisplayNameTCS;

// Ensure that the path bar gets updated for user interaction
// whenever the path changes.We will get the individual directories from
// the updated, most-current path and add them to the UI.
public async Task UpdatePathUIToWorkingDirectoryAsync(string newWorkingDir, string singleItemOverride = null)
{
if (string.IsNullOrWhiteSpace(singleItemOverride))
{
// We need override the path bar when searching, so we use TaskCompletionSource
// to ensure that the override occurs after GetDirectoryPathComponentsWithDisplayNameAsync.
var tcs = new TaskCompletionSource();
_getDisplayNameTCS = tcs;

var components = await StorageFileExtensions.GetDirectoryPathComponentsWithDisplayNameAsync(newWorkingDir);
ToolbarViewModel.PathComponents.Clear();
foreach (var component in components)
ToolbarViewModel.PathComponents.Add(component);

tcs.TrySetResult();
_getDisplayNameTCS = null;
}
else
{
// Wait if awaiting GetDirectoryPathComponentsWithDisplayNameAsync
var tcs = _getDisplayNameTCS;
if (tcs is not null)
await tcs.Task;

// Clear the path UI
ToolbarViewModel.PathComponents.Clear();
ToolbarViewModel.IsSingleItemOverride = true;
Expand Down