[checkbox] fix accessible-action-default when checkbox is disabled (#10173)

This commit is contained in:
Montel Laurent 2025-11-28 17:27:45 +01:00 committed by GitHub
parent 25ec2fb589
commit 80a9f397d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 32 additions and 9 deletions

View file

@ -20,7 +20,7 @@ export component CheckBox {
accessible-label: root.text;
accessible-checked <=> root.checked;
accessible-role: checkbox;
accessible-action-default => { state-layer.clicked(); }
accessible-action-default => { if (root.enabled) {state-layer.clicked();} }
forward-focus: state-layer;
states [

View file

@ -22,8 +22,10 @@ export component CheckBox {
accessible-checked <=> root.checked;
accessible-role: checkbox;
accessible-action-default => {
root.checked = !root.checked;
root.toggled();
if (root.enabled) {
root.checked = !root.checked;
root.toggled();
}
}
forward-focus: i-focus-scope;

View file

@ -21,8 +21,10 @@ export component CheckBox {
accessible-checked <=> root.checked;
accessible-role: checkbox;
accessible-action-default => {
root.checked = !root.checked;
root.toggled();
if (root.enabled) {
root.checked = !root.checked;
root.toggled();
}
}
forward-focus: focus-scope;

View file

@ -20,8 +20,10 @@ export component CheckBox {
accessible-checked <=> root.checked;
accessible-role: checkbox;
accessible-action-default => {
root.checked = !root.checked;
root.toggled();
if (root.enabled) {
root.checked = !root.checked;
root.toggled();
}
}
forward-focus: i-focus-scope;

View file

@ -8,7 +8,9 @@ export component CheckBox inherits NativeCheckBox {
accessible-label <=> root.text;
accessible-role: checkbox;
accessible-action-default => {
root.checked = !root.checked;
root.toggled();
if (root.enabled) {
root.checked = !root.checked;
root.toggled();
}
}
}

View file

@ -6,6 +6,7 @@ export component TestCase inherits Window {
in-out property <string> toggled;
in-out property <bool> checked <=> a.checked;
in-out property <bool> enabled <=> a.enabled;
HorizontalLayout {
alignment: start;
@ -36,10 +37,18 @@ assert_eq!(aaa.accessible_value_minimum(), None);
assert_eq!(aaa.accessible_value_step(), None);
assert_eq!(aaa.accessible_checked(), Some(false));
assert_eq!(aaa.accessible_checkable(), Some(true));
assert_eq!(aaa.accessible_enabled(), Some(true));
aaa.invoke_accessible_default_action();
assert_eq!(instance.get_checked(), true, "CheckBox a was not checked");
assert_eq!(aaa.accessible_checked(), Some(true));
assert_eq!(instance.get_toggled(), SharedString::from("a"));
instance.set_enabled(false);
assert_eq!(aaa.accessible_enabled(), Some(false));
assert_eq!(instance.get_toggled(), SharedString::from("a"));
aaa.invoke_accessible_default_action();
assert_eq!(instance.get_toggled(), SharedString::from("a"));
```
```cpp
@ -60,7 +69,13 @@ aaa.invoke_accessible_default_action();
assert_eq(instance.get_checked(), true);
assert_eq(aaa.accessible_checked().value(), true);
assert_eq(instance.get_toggled(), "a");
assert_eq(aaa.accessible_enabled().value(), true);
instance.set_enabled(false);
assert_eq(aaa.accessible_enabled().value(), false);
assert_eq(instance.get_toggled(), "a");
aaa.invoke_accessible_default_action();
assert_eq(instance.get_toggled(), "a");
```
*/