mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-10-16 10:42:01 +00:00
feat: enhance hyperlink accessibility and automation properties in UI components (#825)
This commit is contained in:
@@ -68,12 +68,14 @@
|
||||
Text="%LANG:AboutProjectLabel%"
|
||||
Style="{DynamicResource ModalInfoLabelTextStyle}"
|
||||
Margin="0,0,16,0"/>
|
||||
<TextBlock x:Name="ProjectLink"
|
||||
<TextBlock
|
||||
Grid.Row="2" Grid.Column="1"
|
||||
Text="https://github.com/Raphire/Win11Debloat"
|
||||
FontSize="13"
|
||||
Style="{DynamicResource HyperlinkStyle}"
|
||||
Margin="0,0,0,0"/>
|
||||
Margin="0,0,0,0">
|
||||
<Hyperlink x:Name="ProjectLink"
|
||||
Style="{DynamicResource InlineHyperlinkStyle}"
|
||||
AutomationProperties.Name="https://github.com/Raphire/Win11Debloat">https://github.com/Raphire/Win11Debloat</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
|
||||
<!-- Separator -->
|
||||
@@ -110,14 +112,16 @@
|
||||
Foreground="{DynamicResource TitleBarCloseHoverColor}"
|
||||
Margin="0,0,8,0"/>
|
||||
|
||||
<TextBlock x:Name="KofiLink"
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
FontSize="16"
|
||||
Style="{DynamicResource HyperlinkStyle}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontWeight="SemiBold"
|
||||
Text="%LANG:AboutKofiLink%"/>
|
||||
FontWeight="SemiBold">
|
||||
<Hyperlink x:Name="KofiLink"
|
||||
Style="{DynamicResource InlineHyperlinkStyle}"
|
||||
AutomationProperties.Name="%LANG:AboutKofiLink%">%LANG:AboutKofiLink%</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
@@ -133,6 +137,7 @@
|
||||
<Button x:Name="CloseButton"
|
||||
Grid.Column="1"
|
||||
Content="%LANG:TitleBarClose%"
|
||||
AutomationProperties.Name="%LANG:TitleBarClose%"
|
||||
Style="{DynamicResource ModalSecondaryStretchedButtonStyle}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
@@ -262,7 +262,7 @@
|
||||
FontWeight="SemiBold"
|
||||
Margin="0,0,0,8"/>
|
||||
|
||||
<ItemsControl x:Name="FeaturesItemsControl" Grid.Row="1">
|
||||
<ItemsControl x:Name="FeaturesItemsControl" Grid.Row="1" Focusable="False" IsTabStop="False">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Vertical" IsItemsHost="True"/>
|
||||
@@ -299,7 +299,7 @@
|
||||
FontWeight="SemiBold"
|
||||
Margin="0,0,0,8"/>
|
||||
|
||||
<ItemsControl x:Name="ReappliedFeaturesItemsControl" Grid.Row="1">
|
||||
<ItemsControl x:Name="ReappliedFeaturesItemsControl" Grid.Row="1" Focusable="False" IsTabStop="False">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Vertical" IsItemsHost="True"/>
|
||||
@@ -329,7 +329,7 @@
|
||||
FontWeight="SemiBold"
|
||||
Margin="0,0,0,8"/>
|
||||
|
||||
<ItemsControl x:Name="NonRevertibleFeaturesItemsControl" Grid.Row="1">
|
||||
<ItemsControl x:Name="NonRevertibleFeaturesItemsControl" Grid.Row="1" Focusable="False" IsTabStop="False">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Vertical" IsItemsHost="True"/>
|
||||
@@ -342,14 +342,16 @@
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<TextBlock x:Name="NonRevertibleWikiLink"
|
||||
<TextBlock
|
||||
Grid.Row="2"
|
||||
Margin="0,8,0,0"
|
||||
Text="%LANG:RestoreWikiLink%"
|
||||
FontSize="13"
|
||||
FontWeight="SemiBold"
|
||||
Style="{DynamicResource HyperlinkStyle}"
|
||||
TextWrapping="Wrap"/>
|
||||
TextWrapping="Wrap">
|
||||
<Hyperlink x:Name="NonRevertibleWikiLink"
|
||||
Style="{DynamicResource InlineHyperlinkStyle}"
|
||||
AutomationProperties.Name="%LANG:RestoreWikiLink%">%LANG:RestoreWikiLink%</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@@ -114,6 +114,20 @@
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!-- Native inline links retain keyboard activation and link automation semantics. -->
|
||||
<Style x:Key="InlineHyperlinkStyle" TargetType="Hyperlink">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ButtonBgColor}"/>
|
||||
<Setter Property="TextDecorations" Value="{x:Null}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ButtonHoverColor}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter Property="TextDecorations" Value="Underline"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!-- ProgressBar Style -->
|
||||
<Style x:Key="ApplyProgressBarStyle" TargetType="ProgressBar">
|
||||
<Setter Property="Background" Value="{DynamicResource ButtonBorderColor}"/>
|
||||
|
||||
@@ -68,12 +68,12 @@ function Show-AboutDialog {
|
||||
})
|
||||
|
||||
# Project link click handler
|
||||
$projectLink.Add_MouseLeftButtonDown({
|
||||
$projectLink.Add_Click({
|
||||
Start-Process "https://github.com/Raphire/Win11Debloat"
|
||||
})
|
||||
|
||||
# Ko-fi link click handler
|
||||
$kofiLink.Add_MouseLeftButtonDown({
|
||||
$kofiLink.Add_Click({
|
||||
Start-Process "https://ko-fi.com/raphire"
|
||||
})
|
||||
|
||||
|
||||
@@ -406,7 +406,7 @@ function Show-RestoreBackupDialog {
|
||||
& $refreshStartMenuUi
|
||||
})
|
||||
|
||||
$nonRevertibleWikiLink.Add_MouseLeftButtonUp({
|
||||
$nonRevertibleWikiLink.Add_Click({
|
||||
try {
|
||||
Start-Process 'https://github.com/Raphire/Win11Debloat/wiki/Reverting-Changes' | Out-Null
|
||||
}
|
||||
|
||||
@@ -50,6 +50,55 @@ Describe 'XAML UI contracts' {
|
||||
}
|
||||
}
|
||||
|
||||
It 'exposes <Schema> links as keyboard-accessible hyperlinks with automation names' -TestCases @(
|
||||
@{ Schema = 'AboutWindow.xaml'; LinkNames = @('ProjectLink', 'KofiLink') }
|
||||
@{ Schema = 'RestoreBackupWindow.xaml'; LinkNames = @('NonRevertibleWikiLink') }
|
||||
) {
|
||||
param($Schema, $LinkNames)
|
||||
|
||||
Add-Type -AssemblyName PresentationFramework
|
||||
$styles = [System.Windows.Markup.XamlReader]::Parse(
|
||||
(Get-Content -LiteralPath (Join-Path $script:SchemaPath 'SharedStyles.xaml') -Raw))
|
||||
$window = [System.Windows.Markup.XamlReader]::Parse(
|
||||
(Get-Content -LiteralPath (Join-Path $script:SchemaPath $Schema) -Raw))
|
||||
try {
|
||||
$window.Resources.MergedDictionaries.Add($styles)
|
||||
foreach ($name in $LinkNames) {
|
||||
$link = $window.FindName($name)
|
||||
$link | Should -BeOfType ([System.Windows.Documents.Hyperlink])
|
||||
$link.Focusable | Should -BeTrue
|
||||
[System.Windows.Input.KeyboardNavigation]::GetIsTabStop($link) | Should -BeTrue
|
||||
$peer = [System.Windows.Automation.Peers.HyperlinkAutomationPeer]::new($link)
|
||||
$peer.GetAutomationControlType() | Should -Be ([System.Windows.Automation.Peers.AutomationControlType]::Hyperlink)
|
||||
$peer.GetName() | Should -Not -BeNullOrEmpty
|
||||
$peer.GetPattern([System.Windows.Automation.Peers.PatternInterface]::Invoke) | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
if ($Schema -eq 'AboutWindow.xaml') {
|
||||
[System.Windows.Automation.AutomationProperties]::GetName($window.FindName('CloseButton')) |
|
||||
Should -Be '%LANG:TitleBarClose%'
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$window.Close()
|
||||
}
|
||||
}
|
||||
|
||||
It 'keeps read-only restore feature lists out of keyboard focus' {
|
||||
Add-Type -AssemblyName PresentationFramework
|
||||
$window = [System.Windows.Markup.XamlReader]::Parse(
|
||||
(Get-Content -LiteralPath (Join-Path $script:SchemaPath 'RestoreBackupWindow.xaml') -Raw))
|
||||
try {
|
||||
foreach ($name in @('FeaturesItemsControl', 'ReappliedFeaturesItemsControl', 'NonRevertibleFeaturesItemsControl')) {
|
||||
$list = $window.FindName($name)
|
||||
$list.Focusable | Should -BeFalse
|
||||
$list.IsTabStop | Should -BeFalse
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$window.Close()
|
||||
}
|
||||
}
|
||||
|
||||
It 'keeps destructive modal actions accessible by automation name' {
|
||||
$applyWindow = Get-Content -LiteralPath (Join-Path $script:SchemaPath 'ApplyChangesWindow.xaml') -Raw
|
||||
$appWindow = Get-Content -LiteralPath (Join-Path $script:SchemaPath 'AppSelectionWindow.xaml') -Raw
|
||||
|
||||
Reference in New Issue
Block a user