diff --git a/src/Files.App/UserControls/AddressToolbar.xaml b/src/Files.App/UserControls/AddressToolbar.xaml index 3d1277e21e45..a0ae5e52707c 100644 --- a/src/Files.App/UserControls/AddressToolbar.xaml +++ b/src/Files.App/UserControls/AddressToolbar.xaml @@ -428,6 +428,7 @@ BorderBrush="{ThemeResource ControlElevationBorderBrush}" BorderThickness="1" CornerRadius="{StaticResource ControlCornerRadius}" + GettingFocus="ClickablePath_GettingFocus" PointerPressed="ManualPathEntryItem_Click" Visibility="{x:Bind converters:MultiBooleanConverter.OrNotConvertToVisibility(ShowSearchBox, ViewModel.IsSearchBoxVisible), Mode=OneWay}"> diff --git a/src/Files.App/UserControls/AddressToolbar.xaml.cs b/src/Files.App/UserControls/AddressToolbar.xaml.cs index 8f09b1905418..2427a1c77c6d 100644 --- a/src/Files.App/UserControls/AddressToolbar.xaml.cs +++ b/src/Files.App/UserControls/AddressToolbar.xaml.cs @@ -73,10 +73,18 @@ private void ManualPathEntryItem_Click(object _, PointerRoutedEventArgs e) ViewModel.IsEditModeEnabled = true; } - private void VisiblePath_KeyDown(object _, KeyRoutedEventArgs e) + private async void VisiblePath_KeyDown(object _, KeyRoutedEventArgs e) { if (e.Key is VirtualKey.Escape) ViewModel.IsEditModeEnabled = false; + + if (e.Key is VirtualKey.Tab) + { + ViewModel.IsEditModeEnabled = false; + // Delay to ensure clickable path is ready to be focused + await Task.Delay(10); + ClickablePath.Focus(FocusState.Keyboard); + } } private void VisiblePath_LostFocus(object _, RoutedEventArgs e) { @@ -216,5 +224,15 @@ private void HistoryItemClicked(ToolbarHistoryItemModel? itemModel) shellPage.Forward_Click(); } } + + private void ClickablePath_GettingFocus(UIElement sender, GettingFocusEventArgs args) + { + if (args.InputDevice != FocusInputDeviceKind.Keyboard) + return; + + var previousControl = args.OldFocusedElement as FrameworkElement; + if (previousControl?.Name == nameof(HomeButton) || previousControl?.Name == nameof(Refresh)) + ViewModel.IsEditModeEnabled = true; + } } }