Skip to content

Commit 25ad08f

Browse files
authored
Various accessibility fixes to Material Design widgets (#9918)
1 parent bbd5d85 commit 25ad08f

File tree

7 files changed

+30
-7
lines changed

7 files changed

+30
-7
lines changed

ui-libraries/material/src/ui/components/filled_icon_button.slint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export component FilledIconButton {
1818
callback clicked();
1919

2020
accessible-role: button;
21-
accessible-enabled: true;
21+
accessible-enabled: root.enabled;
2222
accessible-label: root.tooltip;
2323
accessible-checkable: root.checkable;
2424
accessible-checked: root.checked;

ui-libraries/material/src/ui/components/icon_button.slint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export component IconButton {
2121
callback clicked();
2222

2323
accessible-role: button;
24-
accessible-enabled: true;
24+
accessible-enabled: root.enabled;
2525
accessible-label: root.tooltip;
2626
accessible-checkable: root.checkable;
2727
accessible-checked: root.checked;

ui-libraries/material/src/ui/components/outline_icon_button.slint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export component OutlineIconButton {
1818
callback clicked();
1919

2020
accessible-role: button;
21-
accessible-enabled: true;
21+
accessible-enabled: root.enabled;
2222
accessible-label: root.tooltip;
2323
accessible-checkable: root.checkable;
2424
accessible-checked: root.checked;

ui-libraries/material/src/ui/components/progress_indicator.slint

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ export component LinearProgressIndicator {
88
in property <float> progress;
99
in property <bool> indeterminate;
1010

11+
accessible-role: progress-indicator;
12+
accessible-value: !root.indeterminate ? root.progress : "";
13+
accessible-value-minimum: 0.0;
14+
accessible-value-maximum: 1.0;
1115
height: MaterialStyleMetrics.size_4;
1216

1317
Rectangle {
@@ -34,6 +38,10 @@ export component CircularProgressIndicator {
3438

3539
property <length> bar_height: MaterialStyleMetrics.size_4;
3640

41+
accessible-role: progress-indicator;
42+
accessible-value: !root.indeterminate ? root.progress : "";
43+
accessible-value-minimum: 0.0;
44+
accessible-value-maximum: 1.0;
3745
width: self.height;
3846
min_height: MaterialStyleMetrics.size_40;
3947

ui-libraries/material/src/ui/components/slider.slint

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export component Slider {
2424
accessible-value-minimum: root.minimum;
2525
accessible-value-maximum: root.maximum;
2626
accessible-value-step: min(steps, (root.maximum - root.minimum) / 100);
27+
accessible-action-set-value(v) => {
28+
if v.is-float() {
29+
root.set_value(v.to-float());
30+
}
31+
}
32+
accessible-action-increment => { root.increment_value(); }
33+
accessible-action-decrement => { root.decrement_value(); }
2734
forward-focus: focus_scope;
2835

2936
focus_scope := FocusScope {
@@ -107,11 +114,11 @@ export component Slider {
107114

108115
key_pressed(event) => {
109116
if event.text == Key.LeftArrow {
110-
root.set_value(root.value - root.steps);
117+
root.decrement_value();
111118
return accept;
112119
}
113120
if event.text == Key.RightArrow {
114-
root.set_value(root.value + root.steps);
121+
root.increment_value();
115122
return accept;
116123
}
117124
reject
@@ -137,4 +144,12 @@ export component Slider {
137144
root.value = clamp(value, root.minimum, root.maximum)
138145
}
139146
}
147+
148+
function increment_value() {
149+
root.set_value(root.value + root.steps);
150+
}
151+
152+
function decrement_value() {
153+
root.set_value(root.value - root.steps);
154+
}
140155
}

ui-libraries/material/src/ui/components/switch.slint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export component Switch {
2525
accessible-enabled: root.enabled;
2626
accessible-checkable: true;
2727
accessible-checked <=> root.checked;
28-
accessible-role: checkbox;
28+
accessible-role: switch;
2929
accessible-action-default => { touch_area.clicked(); }
3030
forward_focus: touch_area;
3131

ui-libraries/material/src/ui/components/tonal_icon_button.slint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export component TonalIconButton {
1818
callback clicked();
1919

2020
accessible-role: button;
21-
accessible-enabled: true;
21+
accessible-enabled: root.enabled;
2222
accessible-label: root.tooltip;
2323
accessible-checkable: root.checkable;
2424
accessible-checked: root.checked;

0 commit comments

Comments
 (0)