Skip to content

Commit 35a7975

Browse files
committed
enhance: auto-focus the first input element in popup (#2172)
Signed-off-by: leo <longshuang@msn.cn>
1 parent e78815e commit 35a7975

33 files changed

+125
-75
lines changed

src/Resources/Styles.axaml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@
182182
<Setter Property="FontSize" Value="{Binding Source={x:Static vm:Preferences.Instance}, Path=DefaultFontSize}"/>
183183
</Style>
184184

185+
<Style Selector="AdornerLayer">
186+
<Setter Property="DefaultFocusAdorner">
187+
<FocusAdornerTemplate>
188+
<Rectangle Margin="0" Stroke="{DynamicResource Brush.FG1}" StrokeDashArray="1,2" StrokeThickness="1"/>
189+
</FocusAdornerTemplate>
190+
</Setter>
191+
</Style>
192+
185193
<Style Selector="ToolTip">
186194
<Setter Property="Foreground" Value="{DynamicResource Brush.FG1}"/>
187195
<Setter Property="Background" Value="{DynamicResource Brush.Popup}"/>
@@ -1067,6 +1075,12 @@
10671075
</Style>
10681076

10691077
<Style Selector="CheckBox">
1078+
<Setter Property="FocusAdorner">
1079+
<FocusAdornerTemplate>
1080+
<Border/>
1081+
</FocusAdornerTemplate>
1082+
</Setter>
1083+
10701084
<Setter Property="VerticalAlignment" Value="Center"/>
10711085
<Setter Property="Template">
10721086
<ControlTemplate>
@@ -1085,7 +1099,14 @@
10851099
</Grid>
10861100
</ControlTemplate>
10871101
</Setter>
1088-
1102+
1103+
<Style Selector="^:focus-visible /template/ Border#Border">
1104+
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}"/>
1105+
<Setter Property="Background" Value="{DynamicResource Brush.Accent}"/>
1106+
</Style>
1107+
<Style Selector="^:focus-visible /template/ Path#Icon">
1108+
<Setter Property="Fill" Value="White"/>
1109+
</Style>
10891110
<Style Selector="^:pointerover /template/ Border#Border">
10901111
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}"/>
10911112
</Style>
@@ -1095,6 +1116,12 @@
10951116
</Style>
10961117

10971118
<Style Selector="RadioButton">
1119+
<Setter Property="FocusAdorner">
1120+
<FocusAdornerTemplate>
1121+
<Border/>
1122+
</FocusAdornerTemplate>
1123+
</Setter>
1124+
10981125
<Setter Property="Template">
10991126
<ControlTemplate>
11001127
<Grid ColumnDefinitions="16,*" Background="Transparent">
@@ -1136,9 +1163,26 @@
11361163
<Style Selector="^:checked /template/ Ellipse#Dot">
11371164
<Setter Property="Fill" Value="{DynamicResource Brush.Accent}"/>
11381165
</Style>
1166+
<Style Selector="^:focus-visible /template/ Ellipse#Border">
1167+
<Setter Property="Stroke" Value="{DynamicResource Brush.Accent}"/>
1168+
<Setter Property="Fill" Value="{DynamicResource Brush.Accent}"/>
1169+
</Style>
1170+
<Style Selector="^:focus-visible /template/ Ellipse#Dot">
1171+
<Setter Property="Stroke" Value="White"/>
1172+
<Setter Property="Fill" Value="White"/>
1173+
</Style>
1174+
<Style Selector="^:focus-visible:checked /template/ Ellipse#Dot">
1175+
<Setter Property="Fill" Value="{DynamicResource Brush.Accent}"/>
1176+
</Style>
11391177
</Style>
11401178

11411179
<Style Selector="RadioButton.switch_button">
1180+
<Setter Property="FocusAdorner">
1181+
<FocusAdornerTemplate>
1182+
<Rectangle Margin="0" Stroke="{DynamicResource Brush.FG1}" StrokeDashArray="1,2" StrokeThickness="1"/>
1183+
</FocusAdornerTemplate>
1184+
</Setter>
1185+
11421186
<Setter Property="Height" Value="24"/>
11431187
<Setter Property="BorderThickness" Value="0"/>
11441188
<Setter Property="Background" Value="Transparent"/>

src/Views/AddRemote.axaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
VerticalAlignment="Center"
3030
CornerRadius="2"
3131
Watermark="{DynamicResource Text.Remote.Name.Placeholder}"
32-
Text="{Binding Name, Mode=TwoWay}"
33-
v:AutoFocusBehaviour.IsEnabled="True"/>
32+
Text="{Binding Name, Mode=TwoWay}"/>
3433

3534
<TextBlock Grid.Row="1" Grid.Column="0"
3635
HorizontalAlignment="Right" VerticalAlignment="Center"

src/Views/AddSubmodule.axaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:vm="using:SourceGit.ViewModels"
6-
xmlns:v="using:SourceGit.Views"
76
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="450"
87
x:Class="SourceGit.Views.AddSubmodule"
98
x:DataType="vm:AddSubmodule">
@@ -28,8 +27,7 @@
2827
VerticalAlignment="Center"
2928
CornerRadius="2"
3029
Watermark="{DynamicResource Text.RepositoryURL}"
31-
Text="{Binding Url, Mode=TwoWay}"
32-
v:AutoFocusBehaviour.IsEnabled="True"/>
30+
Text="{Binding Url, Mode=TwoWay}"/>
3331

3432
<TextBlock Grid.Row="1" Grid.Column="0"
3533
HorizontalAlignment="Right" VerticalAlignment="Center"

src/Views/AddToIgnore.axaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:m="using:SourceGit.Models"
66
xmlns:vm="using:SourceGit.ViewModels"
7-
xmlns:v="using:SourceGit.Views"
87
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
98
x:Class="SourceGit.Views.AddToIgnore"
109
x:DataType="vm:AddToIgnore">
@@ -27,8 +26,7 @@
2726
<TextBox Grid.Row="0" Grid.Column="1"
2827
Height="28"
2928
CornerRadius="3"
30-
Text="{Binding Pattern, Mode=TwoWay}"
31-
v:AutoFocusBehaviour.IsEnabled="True">
29+
Text="{Binding Pattern, Mode=TwoWay}">
3230
<TextBox.InnerLeftContent>
3331
<Path Width="12" Height="12" Margin="6,0,2,0" Data="{StaticResource Icons.Pattern}" Fill="{DynamicResource Brush.FG2}"/>
3432
</TextBox.InnerLeftContent>

src/Views/Apply.axaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:m="using:SourceGit.Models"
66
xmlns:vm="using:SourceGit.ViewModels"
7-
xmlns:v="using:SourceGit.Views"
87
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
98
x:Class="SourceGit.Views.Apply"
109
x:DataType="vm:Apply">
@@ -29,8 +28,7 @@
2928
Height="28"
3029
CornerRadius="3"
3130
Watermark="{DynamicResource Text.Apply.File.Placeholder}"
32-
Text="{Binding PatchFile, Mode=TwoWay}"
33-
v:AutoFocusBehaviour.IsEnabled="True">
31+
Text="{Binding PatchFile, Mode=TwoWay}">
3432
<TextBox.InnerRightContent>
3533
<Button Classes="icon_button" Width="30" Height="30" Click="SelectPatchFile">
3634
<Path Data="{StaticResource Icons.Folder.Open}" Fill="{DynamicResource Brush.FG1}"/>

src/Views/Archive.axaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:m="using:SourceGit.Models"
66
xmlns:vm="using:SourceGit.ViewModels"
7-
xmlns:v="using:SourceGit.Views"
87
xmlns:c="using:SourceGit.Converters"
98
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="450"
109
x:Class="SourceGit.Views.Archive"
@@ -60,8 +59,7 @@
6059
Height="28"
6160
CornerRadius="3"
6261
Watermark="{DynamicResource Text.Archive.File.Placeholder}"
63-
Text="{Binding SaveFile, Mode=TwoWay}"
64-
v:AutoFocusBehaviour.IsEnabled="True">
62+
Text="{Binding SaveFile, Mode=TwoWay}">
6563
<TextBox.InnerRightContent>
6664
<Button Classes="icon_button" Width="30" Height="30" Click="SelectOutputFile">
6765
<Path Data="{StaticResource Icons.Folder.Open}" Fill="{DynamicResource Brush.FG1}"/>

src/Views/Clone.axaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:vm="using:SourceGit.ViewModels"
6-
xmlns:v="using:SourceGit.Views"
76
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
87
x:Class="SourceGit.Views.Clone"
98
x:DataType="vm:Clone">
@@ -27,8 +26,7 @@
2726
<TextBox Grid.Row="0" Grid.Column="1"
2827
Height="28"
2928
CornerRadius="3"
30-
Text="{Binding Remote, Mode=TwoWay}"
31-
v:AutoFocusBehaviour.IsEnabled="True"/>
29+
Text="{Binding Remote, Mode=TwoWay}"/>
3230

3331
<TextBlock Grid.Row="1" Grid.Column="0"
3432
HorizontalAlignment="Right"

src/Views/CommitChanges.axaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
<GridSplitter Grid.Column="1"
6969
MinWidth="1"
7070
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
71-
Background="Transparent"/>
71+
Background="Transparent"
72+
Focusable="False"/>
7273

7374
<Grid Grid.Column="2">
7475
<Border BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}">

src/Views/Compare.axaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@
159159
<GridSplitter Grid.Column="1"
160160
MinWidth="1"
161161
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
162-
Background="Transparent"/>
162+
Background="Transparent"
163+
Focusable="False"/>
163164

164165
<Grid Grid.Column="2">
165166
<Border BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}">

src/Views/CreateBranch.axaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@
6565
VerticalAlignment="Center"
6666
CornerRadius="2"
6767
Text="{Binding Name, Mode=TwoWay}"
68-
Watermark="{DynamicResource Text.CreateBranch.Name.Placeholder}"
69-
v:AutoFocusBehaviour.IsEnabled="True"/>
68+
Watermark="{DynamicResource Text.CreateBranch.Name.Placeholder}"/>
7069

7170
<TextBlock Grid.Row="2" Grid.Column="0"
7271
HorizontalAlignment="Right" VerticalAlignment="Center"

0 commit comments

Comments
 (0)