fix: docs search resets on result click (#419)
This commit is contained in:
parent
f360cdaaa9
commit
6f79fdd3ae
@ -87,18 +87,20 @@ const SearchModal: FC<SearchModalProps> = ({ open, onClose, searchablePages }) =
|
||||
const [canFocus, setCanFocus] = useState(true);
|
||||
const [search, setSearch] = useState('');
|
||||
|
||||
const handleFocus = () => {
|
||||
const handleFocus = useCallback(() => {
|
||||
if (canFocus && open && inputRef.current) {
|
||||
inputRef.current?.focus();
|
||||
setSearch('');
|
||||
setCanFocus(false);
|
||||
}
|
||||
};
|
||||
}, [canFocus, open]);
|
||||
|
||||
const handleClose = useCallback(() => {
|
||||
setCanFocus(true);
|
||||
setTimeout(() => {
|
||||
onClose();
|
||||
setTimeout(() => {
|
||||
setCanFocus(true);
|
||||
}, 100);
|
||||
}, 100);
|
||||
}, [onClose]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user