Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit becede3

Browse files
authored
Merge pull request #2332 from github/fixes/2323-keyboard-navigation
Fix keyboard navigation and focus on clone dialog
2 parents dba7be9 + 934292a commit becede3

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

src/GitHub.VisualStudio.UI/Views/Dialog/Clone/RepositoryCloneView.xaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,30 @@
2626
IsDefault="True"
2727
Command="{Binding Clone}"
2828
Content="Clone"
29-
AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.CloneRepositoryButton}"/>
29+
AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.CloneRepositoryButton}"
30+
KeyboardNavigation.TabIndex="5" />
3031

3132
<Button
3233
Margin="6,0,0,0"
3334
HorizontalAlignment="Center"
3435
IsDefault="True"
3536
Command="{Binding Open}"
3637
Content="Open"
37-
AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.OpenRepositoryButton}"/>
38+
AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.OpenRepositoryButton}"
39+
KeyboardNavigation.TabIndex="6"/>
3840
</StackPanel>
3941

4042
<DockPanel DockPanel.Dock="Bottom" Margin="0,9,0,0">
4143
<Label DockPanel.Dock="Left" Content="{x:Static ghfvs:Resources.localPathText}" />
4244
<Button DockPanel.Dock="Right"
4345
Command="{Binding Browse}"
44-
VerticalContentAlignment="Center">
46+
VerticalContentAlignment="Center"
47+
KeyboardNavigation.TabIndex="4">
4548
Browse...
4649
</Button>
4750
<TextBox Text="{Binding Path, UpdateSourceTrigger=PropertyChanged}" Margin="6,0"
48-
VerticalContentAlignment="Center" />
51+
VerticalContentAlignment="Center"
52+
KeyboardNavigation.TabIndex="3" />
4953
</DockPanel>
5054

5155
<uic:InfoPanel Message="{Binding PathWarning}"

src/GitHub.VisualStudio.UI/Views/Dialog/Clone/SelectPageView.xaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@
1414
</Control.Resources>
1515

1616
<DockPanel>
17-
<ghfvs:PromptTextBox DockPanel.Dock="Top"
17+
<ghfvs:PromptTextBox Name="SearchTextBox"
18+
DockPanel.Dock="Top"
1819
Margin="0,9"
19-
PromptText="Search or enter a URL"
20-
Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged, Delay=300}"/>
20+
PromptText="Search or enter a URL"
21+
Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged, Delay=300}"
22+
KeyboardNavigation.TabIndex="1" />
2123

2224
<Grid>
2325
<ListView BorderThickness="0"
2426
ItemsSource="{Binding ItemsView}"
2527
SelectedItem="{Binding SelectedItem}"
2628
VirtualizingPanel.IsVirtualizing="True"
27-
VirtualizingPanel.IsVirtualizingWhenGrouping="True">
29+
VirtualizingPanel.IsVirtualizingWhenGrouping="True"
30+
KeyboardNavigation.TabIndex="2">
2831
<ListView.GroupStyle>
2932
<GroupStyle>
3033
<GroupStyle.HeaderTemplate>

src/GitHub.VisualStudio.UI/Views/Dialog/Clone/SelectPageView.xaml.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using System.ComponentModel.Composition;
1+
using System;
2+
using System.ComponentModel.Composition;
23
using System.Windows.Controls;
34
using System.Windows.Input;
5+
using System.Windows.Threading;
46
using GitHub.Exports;
57
using GitHub.ViewModels.Dialog.Clone;
68

@@ -13,6 +15,16 @@ public partial class SelectPageView : UserControl
1315
public SelectPageView()
1416
{
1517
InitializeComponent();
18+
19+
// See Douglas Stockwell's suggestion:
20+
// https://social.msdn.microsoft.com/Forums/vstudio/en-US/30ed27ce-f7b7-48ae-8adc-0400b9b9ec78
21+
IsVisibleChanged += (sender, e) =>
22+
{
23+
if (IsVisible)
24+
{
25+
Dispatcher.BeginInvoke(DispatcherPriority.Input, (Action)(() => SearchTextBox.Focus()));
26+
}
27+
};
1628
}
1729

1830
protected override void OnPreviewMouseDown(MouseButtonEventArgs e)

0 commit comments

Comments
 (0)