mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
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:
parent
632971af26
commit
9dc56d420f
1 changed files with 21 additions and 19 deletions
|
@ -449,32 +449,34 @@ impl Dialog {
|
||||||
|
|
||||||
let modal = Modal::new("select_element_picker".into()).area(area);
|
let modal = Modal::new("select_element_picker".into()).area(area);
|
||||||
modal.show(ctx, |ui| {
|
modal.show(ctx, |ui| {
|
||||||
for option_or_optgroup in prompt.options() {
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||||
match &option_or_optgroup {
|
for option_or_optgroup in prompt.options() {
|
||||||
SelectElementOptionOrOptgroup::Option(option) => {
|
match &option_or_optgroup {
|
||||||
display_option(
|
SelectElementOptionOrOptgroup::Option(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 {
|
|
||||||
display_option(
|
display_option(
|
||||||
ui,
|
ui,
|
||||||
option,
|
option,
|
||||||
&mut selected_option,
|
&mut selected_option,
|
||||||
&mut is_open,
|
&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);
|
prompt.select(selected_option);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue