fix(dropdown::multi): panic on missing paragraph
This commit is contained in:
parent
2b9e0c09ee
commit
74ee508427
1 changed files with 11 additions and 5 deletions
|
|
@ -443,11 +443,17 @@ pub fn overlay<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static
|
||||||
}
|
}
|
||||||
|
|
||||||
super::menu::OptionElement::Option((option, item)) => {
|
super::menu::OptionElement::Option((option, item)) => {
|
||||||
let selection_index = state
|
let selection_index = state.selections.iter().position(|(i, _)| i == item);
|
||||||
.selections
|
|
||||||
.iter()
|
let selection_index = match selection_index {
|
||||||
.position(|(i, _)| i == item)
|
Some(index) => index,
|
||||||
.expect("selection missing from state");
|
None => {
|
||||||
|
state
|
||||||
|
.selections
|
||||||
|
.push((item.clone(), crate::Paragraph::new()));
|
||||||
|
state.selections.len() - 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let paragraph = &mut state.selections[selection_index].1;
|
let paragraph = &mut state.selections[selection_index].1;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue