fix(dropdown): refresh popup when selections change

This commit is contained in:
Michael Aaron Murphy 2025-11-18 18:47:24 +01:00 committed by Michael Murphy
parent 7eecbe30d7
commit fc85fcac3e

View file

@ -178,6 +178,8 @@ where
fn diff(&mut self, tree: &mut Tree) { fn diff(&mut self, tree: &mut Tree) {
let state = tree.state.downcast_mut::<State>(); let state = tree.state.downcast_mut::<State>();
let mut selections_changed = state.selections.len() != self.selections.len();
state state
.selections .selections
.resize_with(self.selections.len(), crate::Plain::default); .resize_with(self.selections.len(), crate::Plain::default);
@ -192,6 +194,7 @@ where
continue; continue;
} }
selections_changed = true;
state.hashes[i] = text_hash; state.hashes[i] = text_hash;
state.selections[i].update(Text { state.selections[i].update(Text {
content: selection.as_ref(), content: selection.as_ref(),
@ -206,6 +209,11 @@ where
wrapping: text::Wrapping::default(), wrapping: text::Wrapping::default(),
}); });
} }
if state.is_open.load(Ordering::SeqCst) && selections_changed {
state.close_operation = true;
state.open_operation = true;
}
} }
fn size(&self) -> Size<Length> { fn size(&self) -> Size<Length> {