fix(editable_input): disable edit mode when widget loses focus

This commit is contained in:
Michael Aaron Murphy 2024-04-11 20:33:17 +02:00 committed by Michael Murphy
parent 0d829886fe
commit c6ab6cfe23

View file

@ -719,6 +719,14 @@ where
let line_height = self.line_height;
if self.is_editable {
if let Some(ref on_edit) = self.on_toggle_edit {
let state = tree.state.downcast_mut::<State>();
if !state.is_read_only && state.is_focused.is_none() {
state.is_read_only = true;
shell.publish((on_edit)(false));
}
}
let index = tree.children.len() - 1;
if let (Some(trailing_icon), Some(tree)) =
(self.trailing_icon.as_mut(), tree.children.get_mut(index))