fix: widget unfocus on mouse click

This commit is contained in:
Michael Aaron Murphy 2024-07-20 05:55:03 +02:00 committed by Michael Murphy
parent 6f2c893cf5
commit 5474232796
3 changed files with 3 additions and 44 deletions

View file

@ -1210,19 +1210,15 @@ where
let state = state();
let is_clicked = cursor_position.is_over(text_layout.bounds()) && on_input.is_some();
state.is_focused = if is_clicked {
state.is_focused.or_else(|| {
if is_clicked {
state.is_focused = state.is_focused.or_else(|| {
let now = Instant::now();
Some(Focus {
updated_at: now,
now,
})
})
} else {
None
};
});
if is_clicked {
let Some(pos) = cursor_position.position() else {
return event::Status::Ignored;
};