From 80a9f397d930198c4e41cd5ff208ba64ddcccb10 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Fri, 28 Nov 2025 17:27:45 +0100 Subject: [PATCH] [checkbox] fix accessible-action-default when checkbox is disabled (#10173) --- internal/compiler/widgets/cosmic/checkbox.slint | 2 +- .../compiler/widgets/cupertino/checkbox.slint | 6 ++++-- internal/compiler/widgets/fluent/checkbox.slint | 6 ++++-- internal/compiler/widgets/material/checkbox.slint | 6 ++++-- internal/compiler/widgets/qt/checkbox.slint | 6 ++++-- tests/cases/widgets/checkbox.slint | 15 +++++++++++++++ 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/internal/compiler/widgets/cosmic/checkbox.slint b/internal/compiler/widgets/cosmic/checkbox.slint index ee26df08b7..f8c75f341b 100644 --- a/internal/compiler/widgets/cosmic/checkbox.slint +++ b/internal/compiler/widgets/cosmic/checkbox.slint @@ -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 [ diff --git a/internal/compiler/widgets/cupertino/checkbox.slint b/internal/compiler/widgets/cupertino/checkbox.slint index 30fca90269..d044d05c48 100644 --- a/internal/compiler/widgets/cupertino/checkbox.slint +++ b/internal/compiler/widgets/cupertino/checkbox.slint @@ -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; diff --git a/internal/compiler/widgets/fluent/checkbox.slint b/internal/compiler/widgets/fluent/checkbox.slint index 43b74f33cc..d8349d86f0 100644 --- a/internal/compiler/widgets/fluent/checkbox.slint +++ b/internal/compiler/widgets/fluent/checkbox.slint @@ -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; diff --git a/internal/compiler/widgets/material/checkbox.slint b/internal/compiler/widgets/material/checkbox.slint index 422d61b636..b3d0b66cbe 100644 --- a/internal/compiler/widgets/material/checkbox.slint +++ b/internal/compiler/widgets/material/checkbox.slint @@ -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; diff --git a/internal/compiler/widgets/qt/checkbox.slint b/internal/compiler/widgets/qt/checkbox.slint index 1a130de981..6446efe5e0 100644 --- a/internal/compiler/widgets/qt/checkbox.slint +++ b/internal/compiler/widgets/qt/checkbox.slint @@ -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(); + } } } diff --git a/tests/cases/widgets/checkbox.slint b/tests/cases/widgets/checkbox.slint index a1cfe9d786..d081726841 100644 --- a/tests/cases/widgets/checkbox.slint +++ b/tests/cases/widgets/checkbox.slint @@ -6,6 +6,7 @@ export component TestCase inherits Window { in-out property toggled; in-out property checked <=> a.checked; + in-out property 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"); ``` */