Fix screen reader button accessibility and category navigation (#4944)

* Fix UI automation peer wrapping and category focusability

* Add accessibility name to SettingsButton

* Avoid nesting ScrollViewer in generated panels with outer viewers

Inspect targetGrid and its parent hierarchy in Invoke-WPFUIElements to avoid adding an inner ScrollViewer when an outer ScrollViewer already exists.
This commit is contained in:
makhlwf
2026-08-09 18:02:53 -05:00
committed by GitHub
parent 53fc260cc0
commit afc3e1eec2
4 changed files with 86 additions and 46 deletions
@@ -90,18 +90,25 @@ function Find-TweaksByNameOrDescription {
}
if ($dockPanel -is [Windows.Controls.DockPanel]) {
$itemsControl = $null
$itemsControl = $dockPanel.Children | Where-Object { $_ -is [Windows.Controls.ItemsControl] } | Select-Object -First 1
$container = $dockPanel.Children | Where-Object { $_ -is [Windows.Controls.ItemsControl] -or $_ -is [Windows.Controls.StackPanel] -or $_ -is [Windows.Controls.ScrollViewer] -or $_.GetType().Name -eq "ItemsControl" } | Select-Object -First 1
if ($null -ne $itemsControl) {
if ($null -ne $container) {
$targetPanel = if ($container.PSObject.Properties['Content'] -and $null -ne $container.Content) { $container.Content } else { $container }
$items = $null
if ($targetPanel -is [Windows.Controls.ItemsControl] -or $targetPanel.GetType().Name -eq "ItemsControl") {
$items = $targetPanel.Items
}
else {
$items = $targetPanel.Children
}
# Show all items in the category
foreach ($item in $itemsControl.Items) {
foreach ($item in $items) {
if ($null -ne $item) {
# Check if it's a category label (first Label in the ItemsControl)
if ($item -is [Windows.Controls.Label]) {
# Check if it's a category label (first Label in the container)
if ($item -is [Windows.Controls.Label] -or $item.GetType().Name -eq "Label") {
$item.Visibility = [Windows.Visibility]::Visible
}
elseif ($item -is [Windows.Controls.DockPanel] -or $item -is [Windows.Controls.StackPanel]) {
elseif ($item -is [Windows.Controls.DockPanel] -or $item -is [Windows.Controls.StackPanel] -or $item.GetType().Name -eq "DockPanel" -or $item.GetType().Name -eq "StackPanel") {
# Show all checkbox containers
$item.Visibility = [Windows.Visibility]::Visible
}
@@ -143,16 +150,21 @@ function Find-TweaksByNameOrDescription {
}
if ($dockPanel -is [Windows.Controls.DockPanel]) {
$itemsControl = $null
$itemsControl = $dockPanel.Children | Where-Object { $_ -is [Windows.Controls.ItemsControl] } | Select-Object -First 1
$container = $dockPanel.Children | Where-Object { $_ -is [Windows.Controls.ItemsControl] -or $_ -is [Windows.Controls.StackPanel] -or $_ -is [Windows.Controls.ScrollViewer] -or $_.GetType().Name -eq "ItemsControl" } | Select-Object -First 1
if ($null -ne $itemsControl) {
if ($null -ne $container) {
$categoryLabel = $null
# Process all items (checkboxes, labels, panels) in the ItemsControl
for ($i = 0; $i -lt $itemsControl.Items.Count; $i++) {
$item = $itemsControl.Items[$i]
$targetPanel = if ($container.PSObject.Properties['Content'] -and $null -ne $container.Content) { $container.Content } else { $container }
$items = $null
if ($targetPanel -is [Windows.Controls.ItemsControl] -or $targetPanel.GetType().Name -eq "ItemsControl") {
$items = $targetPanel.Items
}
else {
$items = $targetPanel.Children
}
# Process all items (checkboxes, labels, panels) in the container
foreach ($item in $items) {
if ($null -eq $item) {
continue
}
@@ -161,7 +173,7 @@ function Find-TweaksByNameOrDescription {
# Check if this is a category label (usually first Label)
# ------------------------------------------------------------
if ($item -is [Windows.Controls.Label]) {
if ($item -is [Windows.Controls.Label] -or $item.GetType().Name -eq "Label") {
$categoryLabel = $item
# Initially hide category label; show it only if matches found
$item.Visibility = [Windows.Visibility]::Collapsed
@@ -171,13 +183,13 @@ function Find-TweaksByNameOrDescription {
# Check if this is a DockPanel containing a tweak checkbox
# ------------------------------------------------------------
elseif ($item -is [Windows.Controls.DockPanel]) {
elseif ($item -is [Windows.Controls.DockPanel] -or $item.GetType().Name -eq "DockPanel") {
$checkbox = $null
$label = $null
# Safely extract checkbox and label
$checkbox = $item.Children | Where-Object { $_ -is [Windows.Controls.CheckBox] } | Select-Object -First 1
$label = $item.Children | Where-Object { $_ -is [Windows.Controls.Label] } | Select-Object -First 1
$checkbox = $item.Children | Where-Object { $_ -is [Windows.Controls.CheckBox] -or $_.GetType().Name -eq "CheckBox" } | Select-Object -First 1
$label = $item.Children | Where-Object { $_ -is [Windows.Controls.Label] -or $_.GetType().Name -eq "Label" } | Select-Object -First 1
# Check if tweak matches search criteria
$itemMatches = $false
@@ -221,9 +233,9 @@ function Find-TweaksByNameOrDescription {
# Check if this is a StackPanel containing a tweak checkbox
# ------------------------------------------------------------
elseif ($item -is [Windows.Controls.StackPanel]) {
elseif ($item -is [Windows.Controls.StackPanel] -or $item.GetType().Name -eq "StackPanel") {
$checkbox = $null
$checkbox = $item.Children | Where-Object { $_ -is [Windows.Controls.CheckBox] } | Select-Object -First 1
$checkbox = $item.Children | Where-Object { $_ -is [Windows.Controls.CheckBox] -or $_.GetType().Name -eq "CheckBox" } | Select-Object -First 1
$itemMatches = $false