Skip to content
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
28 changes: 28 additions & 0 deletions src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public sealed partial class ColumnLayoutPage : BaseGroupableLayoutPage
// so SelectionChanged (which has no PointerDeviceType of its own) can honor input-method-aware single-click settings.
private PointerDeviceType? lastPointerDeviceType;

// True if the most recent PointerPressed had the right button down, so SelectionChanged
// (which has no pointer info) can skip auto-opening folders on right-click.
private bool isRightButtonPressed;

public event EventHandler? ItemInvoked;
public event EventHandler? ItemTapped;

Expand Down Expand Up @@ -377,6 +381,14 @@ private void TryOpenSelectedFolder()
if (openedFolderPresenter == FileList.ContainerFromItem(SelectedItem))
return;

// Right-click should never navigate into the folder; close any stale subcolumn since
// selection moved away from its source folder (#18584).
if (isRightButtonPressed)
{
CloseFolder();
return;
}

// Open the selected folder if selected through tap
if (UserSettingsService.FoldersSettingsService.OpenFoldersInColumnsViewWithSingleClick.ShouldOpenWithSingleClick(lastPointerDeviceType))
ItemInvoked?.Invoke(new ColumnParam { Source = this, NavPathParam = (SelectedItem is IShortcutItem sht ? sht.TargetPath : SelectedItem.ItemPath), ListView = FileList }, EventArgs.Empty);
Expand Down Expand Up @@ -413,13 +425,19 @@ private void FileList_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
if (!IsRenamingItem)
HandleRightClick();

// The right-click selection-change has already been consumed by OnSelectionChanged;
// clear the flag so the next interaction (e.g. a left-click whose PointerPressed
// the ListView may swallow) is treated as a normal navigation.
isRightButtonPressed = false;
}

protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
{
// Keyboard navigation has no pointer device; clear the cached value so SelectionChanged
// falls back to the helper's "null is mouse-like" semantics instead of using a stale device.
lastPointerDeviceType = null;
isRightButtonPressed = false;

if
(
Expand Down Expand Up @@ -534,6 +552,7 @@ private void FileList_Holding(object sender, HoldingRoutedEventArgs e)
private void FileList_PointerPressed(object sender, PointerRoutedEventArgs e)
{
lastPointerDeviceType = e.Pointer.PointerDeviceType;
isRightButtonPressed = e.GetCurrentPoint(null).Properties.IsRightButtonPressed;
}

private void HandleRightClick()
Expand Down Expand Up @@ -563,6 +582,15 @@ private async void FileList_ItemTapped(object sender, TappedRoutedEventArgs e)
ResetRenameDoubleClick();
await Commands.OpenItem.ExecuteAsync();
}
else if (isItemFolder
&& openedFolderPresenter != FileList.ContainerFromItem(item)
&& UserSettingsService.FoldersSettingsService.OpenFoldersInColumnsViewWithSingleClick.ShouldOpenWithSingleClick(e.PointerDeviceType))
{
// SelectionChanged won't fire if the folder is already selected (e.g. from a prior right-click),
// so drive the single-click open from here too (#18584).
ResetRenameDoubleClick();
ItemInvoked?.Invoke(new ColumnParam { Source = this, NavPathParam = (item is IShortcutItem sht ? sht.TargetPath : item!.ItemPath), ListView = FileList }, EventArgs.Empty);
}
else if (item is not null)
{
var clickedItem = e.OriginalSource as FrameworkElement;
Expand Down
Loading