Skip to content

Commit eb05526

Browse files
authored
Fix: Fixed tab navigation when middle-clicking a sidebar item (#12620)
1 parent 83dd189 commit eb05526

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -412,25 +412,29 @@ private void FormatDrive()
412412

413413
private async void Sidebar_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
414414
{
415-
if (IsInPointerPressed || args.InvokedItem is null || args.InvokedItemContainer is null)
415+
try
416416
{
417-
IsInPointerPressed = false;
418-
return;
419-
}
417+
if (args.InvokedItem is null || args.InvokedItemContainer is null)
418+
return;
420419

421-
var navigationPath = args.InvokedItemContainer.Tag?.ToString();
420+
var navigationPath = args.InvokedItemContainer.Tag?.ToString();
422421

423-
if (await DriveHelpers.CheckEmptyDrive(navigationPath))
424-
return;
422+
if (await DriveHelpers.CheckEmptyDrive(navigationPath))
423+
return;
424+
425+
var ctrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
426+
if ((IsInPointerPressed || ctrlPressed) && navigationPath is not null)
427+
{
428+
await NavigationHelpers.OpenPathInNewTab(navigationPath);
429+
return;
430+
}
425431

426-
var ctrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
427-
if (ctrlPressed && navigationPath is not null)
432+
SidebarItemInvoked?.Invoke(this, new SidebarItemInvokedEventArgs(args.InvokedItemContainer));
433+
}
434+
finally
428435
{
429-
await NavigationHelpers.OpenPathInNewTab(navigationPath);
430-
return;
436+
IsInPointerPressed = false;
431437
}
432-
433-
SidebarItemInvoked?.Invoke(this, new SidebarItemInvokedEventArgs(args.InvokedItemContainer));
434438
}
435439

436440
private async void Sidebar_PointerPressed(object sender, PointerRoutedEventArgs e)
@@ -443,7 +447,6 @@ private async void Sidebar_PointerPressed(object sender, PointerRoutedEventArgs
443447

444448
IsInPointerPressed = true;
445449
e.Handled = true;
446-
await NavigationHelpers.OpenPathInNewTab(item?.Path);
447450
}
448451

449452
private void PaneRoot_RightTapped(object sender, RightTappedRoutedEventArgs e)

0 commit comments

Comments
 (0)