servoshell: Make list of options in <select> prompt scrollable (#36677)

This ensures that the select element is usable when there are a lot of
options.

Testing: We don't have tests for servoshell.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2025-04-24 13:59:54 +02:00 committed by GitHub
parent 632971af26
commit 9dc56d420f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -449,32 +449,34 @@ impl Dialog {
let modal = Modal::new("select_element_picker".into()).area(area);
modal.show(ctx, |ui| {
for option_or_optgroup in prompt.options() {
match &option_or_optgroup {
SelectElementOptionOrOptgroup::Option(option) => {
display_option(
ui,
option,
&mut selected_option,
&mut is_open,
false,
);
},
SelectElementOptionOrOptgroup::Optgroup { label, options } => {
ui.label(egui::RichText::new(label).strong());
for option in options {
egui::ScrollArea::vertical().show(ui, |ui| {
for option_or_optgroup in prompt.options() {
match &option_or_optgroup {
SelectElementOptionOrOptgroup::Option(option) => {
display_option(
ui,
option,
&mut selected_option,
&mut is_open,
true,
false,
);
}
},
},
SelectElementOptionOrOptgroup::Optgroup { label, options } => {
ui.label(egui::RichText::new(label).strong());
for option in options {
display_option(
ui,
option,
&mut selected_option,
&mut is_open,
true,
);
}
},
}
}
}
});
});
prompt.select(selected_option);