diff --git a/internal/compiler/widgets/common/combobox-base.slint b/internal/compiler/widgets/common/combobox-base.slint index e7b8a73fa19..6c87803ba07 100644 --- a/internal/compiler/widgets/common/combobox-base.slint +++ b/internal/compiler/widgets/common/combobox-base.slint @@ -18,7 +18,11 @@ export component ComboBoxBase { return; } root.current-index = index; - root.update-current-value(); + + if root.current-value != root.model[root.current-index] { + root.update-current-value(); + } + root.selected(root.current-value); } diff --git a/tests/cases/widgets/combobox.slint b/tests/cases/widgets/combobox.slint index 171ada1e30e..ade0f68dbe3 100644 --- a/tests/cases/widgets/combobox.slint +++ b/tests/cases/widgets/combobox.slint @@ -35,6 +35,7 @@ use std::rc::Rc; use slint::platform::Key; use slint::SharedString; use slint::VecModel; +use i_slint_backend_testing::mock_elapsed_time; let instance = TestCase::new().unwrap(); @@ -91,10 +92,12 @@ instance.set_output(Default::default()); // Set current-index to -1 instance.set_current_index(-1); +mock_elapsed_time(500); assert_eq!(instance.get_current_value(), &SharedString::from("")); // Replace model instance.set_model(Rc::new(VecModel::from_slice(&[SharedString::from("A"), SharedString::from("B")])).into()); +mock_elapsed_time(500); assert_eq!(instance.get_current_index(), 0); assert_eq!(instance.get_current_value(), &SharedString::from("A"));