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 you couldn't select files in columns layout #12124

Merged
22 changes: 12 additions & 10 deletions src/Files.App/Views/LayoutModes/ColumnViewBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ private void ColumnViewBase_ItemInvoked(object? sender, EventArgs e)
navigationArguments.NavPathParam = column.NavPathParam;
ParentShellPageInstance.TabItemArguments.NavigationArg = column.NavPathParam;
}
else if (UserSettingsService.FoldersSettingsService.ColumnLayoutOpenFoldersWithOneClick &&
arePathsDifferent)
else if (UserSettingsService.FoldersSettingsService.ColumnLayoutOpenFoldersWithOneClick)
{
CloseUnnecessaryColumns(column);
}
Expand Down Expand Up @@ -435,20 +434,18 @@ private void ColumnViewBase_ItemTapped(object? sender, EventArgs e)
var column = sender as ColumnParam;
if (column?.ListView.FindAscendant<ColumnViewBrowser>() != this || string.IsNullOrEmpty(column.NavPathParam))
return;

CloseUnnecessaryColumns(column);
}

private void CloseUnnecessaryColumns(ColumnParam column)
{
var columnPath = ((ColumnHost.ActiveBlades.Last().Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel?.WorkingDirectory;
var columnFirstPath = ((ColumnHost.ActiveBlades.First().Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel.WorkingDirectory;
if (string.IsNullOrEmpty(columnPath) || string.IsNullOrEmpty(columnFirstPath))
return;
var relativeIndex = -1;

while (relativeIndex < ColumnHost.ActiveBlades.Count &&
(!column.NavPathParam?.Equals(GetWorkingDirOfColumnAt(++relativeIndex)) ?? false));

var destComponents = StorageFileExtensions.GetDirectoryPathComponents(column.NavPathParam);
var (_, relativeIndex) = GetLastCommonAndRelativeIndex(destComponents, columnPath, columnFirstPath);
if (relativeIndex >= 0)
if (relativeIndex >= 0 && relativeIndex < ColumnHost.ActiveBlades.Count)
{
ColumnHost.ActiveBlades[relativeIndex].FindDescendant<ColumnViewBase>()?.ClearOpenedFolderSelectionIndicator();
DismissOtherBlades(relativeIndex);
Expand Down Expand Up @@ -481,5 +478,10 @@ private void CloseUnnecessaryColumns(ColumnParam column)
ColumnHost.Items.Add(newblade);
return (frame, newblade);
}

private string? GetWorkingDirOfColumnAt(int index)
{
return ((ColumnHost.ActiveBlades[index].Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel?.WorkingDirectory;
}
}
}