Skip to content

Commit

Permalink
Fix: Fixed keyboard navigation in the address path bar (#16653)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 authored Dec 31, 2024
1 parent 8436c6d commit 84a35eb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Files.App/UserControls/AddressToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}">
<Grid.ColumnDefinitions>
Expand Down
20 changes: 19 additions & 1 deletion src/Files.App/UserControls/AddressToolbar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
}
}

0 comments on commit 84a35eb

Please sign in to comment.