fix caret getting stuck as visible without focus when the text field pauses blinking while it is without focus

This commit is contained in:
temportalflux
2026-07-11 09:31:07 -04:00
parent 09be9ed98e
commit 5bfb5ef58b
2 changed files with 5 additions and 5 deletions
@@ -73,7 +73,7 @@ impl Caret {
{
let handle = cx.subscribe(emitter, |state, _emitter, event, cx| match event {
CaretNotify::PauseBlinking => {
if state.interval.is_zero() {
if state.interval.is_zero() || !state.has_focus {
return;
}
@@ -100,9 +100,9 @@ impl Caret {
return is_focused;
}
match (is_focused, was_focused) {
match (was_focused, is_focused) {
// Caret has a blinking interval, and gained focused.
(true, false) => {
(false, true) => {
self.has_focus = true;
self.paused = false;
@@ -112,7 +112,7 @@ impl Caret {
true
}
// Caret has a blinking interval and lost focus
(false, true) => {
(true, false) => {
self.has_focus = false;
self.visible = false;
self.paused = false;
@@ -1138,8 +1138,8 @@ impl<'app> EditableTextActionHandler<Context<'app, Self>> for EditableTextState
window: &mut Window,
cx: &mut Context<'app, Self>,
) {
let character_pos = self.index_for_pixel_point(text_position, window.line_height());
if self.is_selecting && self.click_count == 1 {
let character_pos = self.index_for_pixel_point(text_position, window.line_height());
self.select_to(character_pos, cx);
}
}