Improve accessibility and testability of ComboBox (#7658)

Changed it to use labeled_by to avoid kittest finding the label when
searching for the ComboBox and also set the value so a screen reader
will know what's selected.
This commit is contained in:
Lucas Meurer
2025-11-13 11:53:50 +01:00
committed by Emil Ernerfeldt
parent 0b9bb5f494
commit d5320fe827
2 changed files with 24 additions and 8 deletions
@@ -61,3 +61,17 @@ fn text_edit_rtl() {
harness.snapshot(format!("text_edit_rtl_{i}"));
}
}
#[test]
fn combobox_should_have_value() {
let harness = Harness::new_ui(|ui| {
egui::ComboBox::from_label("Select an option")
.selected_text("Option 1")
.show_ui(ui, |_ui| {});
});
assert_eq!(
harness.get_by_label("Select an option").value().as_deref(),
Some("Option 1")
);
}