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