Skip to content

Commit

Permalink
fix(dropdown::multi): panic on missing paragraph
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Dec 9, 2023
1 parent 2b9e0c0 commit 74ee508
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/widget/dropdown/multi/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,17 @@ pub fn overlay<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static
}

super::menu::OptionElement::Option((option, item)) => {
let selection_index = state
.selections
.iter()
.position(|(i, _)| i == item)
.expect("selection missing from state");
let selection_index = state.selections.iter().position(|(i, _)| i == item);

let selection_index = match selection_index {
Some(index) => index,
None => {
state
.selections
.push((item.clone(), crate::Paragraph::new()));
state.selections.len() - 1
}
};

let paragraph = &mut state.selections[selection_index].1;

Expand Down

0 comments on commit 74ee508

Please sign in to comment.