Skip to content

Commit ddb6596

Browse files
Enforce SettingsCard accessibility groupings on load
This commit adds a Loaded event handler to the custom SettingsCard widgets (ButtonCard, CheckboxButtonCard, CheckboxCard, SecureCheckboxCard) to strictly enforce their AutomationProperties.Name and LocalizedControlType='grouping'. This prevents the underlying Windows Community Toolkit logic from overriding the grouping name with the internal button's face text upon rendering.
1 parent bab91e1 commit ddb6596

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/UniGetUI/Controls/SettingsWidgets/ButtonCard.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ public ButtonCard()
3838
Click?.Invoke(this, EventArgs.Empty);
3939
};
4040
Content = _button;
41+
42+
Loaded += (s, e) =>
43+
{
44+
Microsoft.UI.Xaml.Automation.AutomationProperties.SetName(this, _text);
45+
Microsoft.UI.Xaml.Automation.AutomationProperties.SetLocalizedControlType(this, "grouping");
46+
};
4147
}
4248
}
4349
}

src/UniGetUI/Controls/SettingsWidgets/CheckboxButtonCard.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ public CheckboxButtonCard()
9999
};
100100

101101
Button.Click += (s, e) => Click?.Invoke(s, e);
102+
103+
Loaded += (s, e) =>
104+
{
105+
Microsoft.UI.Xaml.Automation.AutomationProperties.SetName(this, _textblock.Text);
106+
Microsoft.UI.Xaml.Automation.AutomationProperties.SetLocalizedControlType(this, "grouping");
107+
};
102108
}
103109
}
104110
}

src/UniGetUI/Controls/SettingsWidgets/CheckboxCard.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ public CheckboxCard()
101101

102102
_checkbox.HorizontalAlignment = HorizontalAlignment.Stretch;
103103
_checkbox.Toggled += _checkbox_Toggled;
104+
105+
Loaded += (s, e) =>
106+
{
107+
Microsoft.UI.Xaml.Automation.AutomationProperties.SetName(this, _textblock.Text);
108+
Microsoft.UI.Xaml.Automation.AutomationProperties.SetLocalizedControlType(this, "grouping");
109+
};
104110
}
105111

106112
protected virtual void _checkbox_Toggled(object sender, RoutedEventArgs e)

src/UniGetUI/Controls/SettingsWidgets/SecureCheckboxCard.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ public SecureCheckboxCard()
118118

119119
_checkbox.HorizontalAlignment = HorizontalAlignment.Stretch;
120120
_checkbox.Toggled += (s, e) => _ = _checkbox_Toggled();
121+
122+
Loaded += (s, e) =>
123+
{
124+
Microsoft.UI.Xaml.Automation.AutomationProperties.SetName(this, _textblock.Text);
125+
Microsoft.UI.Xaml.Automation.AutomationProperties.SetLocalizedControlType(this, "grouping");
126+
};
121127
}
122128

123129
protected virtual async Task _checkbox_Toggled()

0 commit comments

Comments
 (0)