fix(text_input): send on_unfocus message where they were missing

This commit is contained in:
Michael Aaron Murphy 2025-03-26 16:34:22 +01:00 committed by Michael Murphy
parent 8bce57ed83
commit c0b0b817e8

View file

@ -650,6 +650,7 @@ where
if let Some(f) = state.is_focused.as_ref() {
if f.updated_at != LAST_FOCUS_UPDATE.with(|f| f.get()) {
state.unfocus();
state.emit_unfocus = true;
}
}
@ -876,6 +877,16 @@ where
}
}
let state = tree.state.downcast_mut::<State>();
if let Some(on_unfocus) = self.on_unfocus.as_ref() {
if state.emit_unfocus {
state.emit_unfocus = false;
eprintln!("unfocus");
shell.publish(on_unfocus.clone());
}
}
let dnd_id = self.dnd_id();
let id = Widget::id(self);
update(
@ -1532,6 +1543,10 @@ pub fn update<'a, Message: Clone + 'static>(
return event::Status::Captured;
} else {
state.unfocus();
if let Some(on_unfocus) = on_unfocus {
shell.publish(on_unfocus.clone());
}
}
}
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
@ -2486,6 +2501,7 @@ pub struct State {
pub dirty: bool,
pub is_secure: bool,
pub is_read_only: bool,
pub emit_unfocus: bool,
select_on_focus: bool,
is_focused: Option<Focus>,
dragging_state: Option<DraggingState>,
@ -2560,6 +2576,7 @@ impl State {
label: crate::Plain::default(),
helper_text: crate::Plain::default(),
is_read_only,
emit_unfocus: false,
is_focused: None,
select_on_focus: false,
dragging_state: None,