Skip to content

Fix: Fixed issue where column view jumps from left to right #11986

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

Merged
Merged
Show file tree
Hide file tree
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
17 changes: 2 additions & 15 deletions src/Files.App/Views/LayoutModes/ColumnViewBase.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using Windows.System;
using Windows.UI.Core;
using static Files.App.Constants;
using DispatcherQueueTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer;

namespace Files.App.Views.LayoutModes
{
Expand All @@ -41,7 +40,6 @@ public ColumnViewBase() : base()
InitializeComponent();
var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged);
selectionRectangle.SelectionEnded += SelectionRectangle_SelectionEnded;
tapDebounceTimer = DispatcherQueue.CreateTimer();
ItemInvoked += ColumnViewBase_ItemInvoked;
GotFocus += ColumnViewBase_GotFocus;
}
Expand Down Expand Up @@ -232,22 +230,11 @@ private void HandleRightClick(object sender, RightTappedRoutedEventArgs e)
HandleRightClick(e.OriginalSource);
}

private readonly DispatcherQueueTimer tapDebounceTimer;

private void FileList_PreviewKeyUp(object sender, KeyRoutedEventArgs e)
{
// Open selected directory
tapDebounceTimer.Stop();
if (IsItemSelected && SelectedItem.PrimaryItemAttribute == StorageItemTypes.Folder)
{
var currItem = SelectedItem;
tapDebounceTimer.Debounce(() =>
{
if (currItem == SelectedItem)
ItemInvoked?.Invoke(new ColumnParam { NavPathParam = (SelectedItem is ShortcutItem sht ? sht.TargetPath : SelectedItem.ItemPath), ListView = FileList }, EventArgs.Empty);
tapDebounceTimer.Stop();
}, TimeSpan.FromMilliseconds(200));
}
if (IsItemSelected && SelectedItem?.PrimaryItemAttribute == StorageItemTypes.Folder)
ItemInvoked?.Invoke(new ColumnParam { NavPathParam = (SelectedItem is ShortcutItem sht ? sht.TargetPath : SelectedItem.ItemPath), ListView = FileList }, EventArgs.Empty);
}

protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
Expand Down
15 changes: 10 additions & 5 deletions src/Files.App/Views/LayoutModes/ColumnViewBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.Storage;
using static Files.App.Constants;
using static Files.App.Helpers.PathNormalization;

Expand Down Expand Up @@ -59,9 +60,10 @@ private void ColumnViewBase_ItemInvoked(object? sender, EventArgs e)
return;

var nextBladeIndex = ColumnHost.ActiveBlades.IndexOf(column.ListView.FindAscendant<BladeItem>()) + 1;
var nextBlade = ColumnHost.ActiveBlades.ElementAtOrDefault(nextBladeIndex);
var arePathsDifferent = ((nextBlade?.Content as Frame)?.Content as IShellPage)?.FilesystemViewModel?.WorkingDirectory != column.NavPathParam;

if (ColumnHost.ActiveBlades.ElementAtOrDefault(nextBladeIndex) is not BladeItem nextBlade ||
((nextBlade.Content as Frame)?.Content as IShellPage)?.FilesystemViewModel?.WorkingDirectory != column.NavPathParam)
if (nextBlade is null || arePathsDifferent)
{
DismissOtherBlades(column.ListView);

Expand All @@ -75,7 +77,8 @@ private void ColumnViewBase_ItemInvoked(object? sender, EventArgs e)
navigationArguments.NavPathParam = column.NavPathParam;
ParentShellPageInstance.TabItemArguments.NavigationArg = column.NavPathParam;
}
else if (UserSettingsService.FoldersSettingsService.ColumnLayoutOpenFoldersWithOneClick)
else if (UserSettingsService.FoldersSettingsService.ColumnLayoutOpenFoldersWithOneClick &&
arePathsDifferent)
{
CloseUnnecessaryColumns(column);
}
Expand Down Expand Up @@ -268,7 +271,9 @@ private void ColumnViewBrowser_ContentChanged(object sender, UserControls.Multit

private void ColumnViewBase_KeyUp(object sender, Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e)
{
CloseUnnecessaryColumns((ActiveColumnShellPage as ColumnShellPage)?.ColumnParams);
var shPage = ActiveColumnShellPage as ColumnShellPage;
if (shPage?.SlimContentPage?.SelectedItem?.PrimaryItemAttribute is not StorageItemTypes.Folder)
CloseUnnecessaryColumns(shPage?.ColumnParams);
}

public void NavigateBack()
Expand Down Expand Up @@ -436,7 +441,7 @@ private void ColumnViewBase_ItemTapped(object? sender, EventArgs e)

private void CloseUnnecessaryColumns(ColumnParam column)
{
var columnPath = ((ColumnHost.ActiveBlades.Last().Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel.WorkingDirectory;
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;
Expand Down