Skip to content

Commit fda6cc2

Browse files
Fix description labels on main SettingsPageButtons
This commit applies AutomationProperties.Name and AutomationProperties.HelpText to the SettingsPageButton custom widget and enforces them on the Loaded event, ensuring that screen readers properly announce the button text alongside its descriptive subtext.
1 parent 09020d3 commit fda6cc2

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

src/UniGetUI/Controls/SettingsWidgets/SettingsPageButton.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,26 @@ namespace UniGetUI.Interface.Widgets
1010
{
1111
public partial class SettingsPageButton : SettingsCard
1212
{
13+
private string _text = "";
1314
public string Text
1415
{
15-
set => Header = CoreTools.Translate(value);
16+
set
17+
{
18+
_text = CoreTools.Translate(value);
19+
Header = _text;
20+
Microsoft.UI.Xaml.Automation.AutomationProperties.SetName(this, _text);
21+
}
1622
}
1723

24+
private string _underText = "";
1825
public string UnderText
1926
{
20-
set => Description = CoreTools.Translate(value);
27+
set
28+
{
29+
_underText = CoreTools.Translate(value);
30+
Description = _underText;
31+
Microsoft.UI.Xaml.Automation.AutomationProperties.SetHelpText(this, _underText);
32+
}
2133
}
2234

2335
public IconType Icon
@@ -30,6 +42,14 @@ public SettingsPageButton()
3042
CornerRadius = new CornerRadius(8);
3143
HorizontalAlignment = HorizontalAlignment.Stretch;
3244
IsClickEnabled = true;
45+
46+
Loaded += (s, e) =>
47+
{
48+
if (!string.IsNullOrEmpty(_text))
49+
Microsoft.UI.Xaml.Automation.AutomationProperties.SetName(this, _text);
50+
if (!string.IsNullOrEmpty(_underText))
51+
Microsoft.UI.Xaml.Automation.AutomationProperties.SetHelpText(this, _underText);
52+
};
3353
}
3454
}
3555
}

0 commit comments

Comments
 (0)