fix(web): suggestions stay open when you return to the search quickly
ci / ts / ts (packages + web) (push) Successful in 1m1s
release / android (APK в релиз) (push) Successful in 4m10s
release / release (версия и заметки) (push) Successful in 6s

Leaving the field scheduled a close 120 ms later; coming back and typing
within that window let the old timer hide the fresh suggestions. Focus now
cancels the pending close. This also made the search box test flaky.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mrleo1nidandClaude Opus 5.5 committed 2026-10-21 00:13:08 +03:00
1 parent 860072e542
commit 823d1eb841
1 file changed
+4 -1
+4 -1
View File
@@ -38,6 +38,7 @@ export function SearchBox({ align = 'center' }: { align?: 'left' | 'center' | 'r
const [open, setOpen] = useState(false);
const [active, setActive] = useState(-1);
const [focused, setFocused] = useState(false);
const blurTimer = useRef<ReturnType<typeof setTimeout>>(undefined);
// Свёрнут в круглую кнопку, пока не нужен: раскрывается по клику, «/» или Ctrl+K.
const expanded = focused || q !== '';
@@ -167,12 +168,14 @@ export function SearchBox({ align = 'center' }: { align?: 'left' | 'center' | 'r
setActive(-1);
}}
onFocus={() => {
// Вернулись в поле раньше, чем сработало закрытие по blur, — подсказки не прячем.
clearTimeout(blurTimer.current);
setFocused(true);
setOpen(true);
}}
onBlur={() => {
setFocused(false);
setTimeout(close, 120);
blurTimer.current = setTimeout(close, 120);
}}
onKeyDown={onKeyDown}
/>