fix(ui): do not focus board search on load

This commit is contained in:
psychedelicious 2024-01-11 23:46:01 +11:00
parent 59437a02c3
commit a24e63d440

View File

@ -3,14 +3,13 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { InvIconButton } from 'common/components/InvIconButton/InvIconButton';
import { boardSearchTextChanged } from 'features/gallery/store/gallerySlice';
import type { ChangeEvent, KeyboardEvent } from 'react';
import { memo, useCallback, useEffect, useRef } from 'react';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { PiXBold } from 'react-icons/pi';
const BoardsSearch = () => {
const dispatch = useAppDispatch();
const boardSearchText = useAppSelector((s) => s.gallery.boardSearchText);
const inputRef = useRef<HTMLInputElement>(null);
const { t } = useTranslation();
const handleBoardSearch = useCallback(
@ -41,18 +40,9 @@ const BoardsSearch = () => {
[handleBoardSearch]
);
useEffect(() => {
// focus the search box on mount
if (!inputRef.current) {
return;
}
inputRef.current.focus();
}, []);
return (
<InputGroup>
<Input
ref={inputRef}
placeholder={t('boards.searchBoard')}
value={boardSearchText}
onKeyDown={handleKeydown}