diff --git a/backend/src/components/BookingFilter.tsx b/backend/src/components/BookingFilter.tsx index 842afe00..b1ec52fa 100644 --- a/backend/src/components/BookingFilter.tsx +++ b/backend/src/components/BookingFilter.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useState, useRef } from 'react' import { FormControl, TextField, @@ -38,6 +38,8 @@ function BookingFilter({ const [keyword, setKeyword] = useState('') const [minDate, setMinDate] = useState() + const inputRef = useRef(null) + const handleSearchChange = (e: React.ChangeEvent) => { setKeyword(e.target.value) } @@ -115,6 +117,7 @@ function BookingFilter({ { setKeyword('') + inputRef.current?.focus() }} > diff --git a/backend/src/components/Search.tsx b/backend/src/components/Search.tsx index 22c2e679..f3aa4aa9 100644 --- a/backend/src/components/Search.tsx +++ b/backend/src/components/Search.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useState, useRef } from 'react' import { IconButton, TextField } from '@mui/material' import { Search as SearchIcon, Clear as ClearIcon } from '@mui/icons-material' import { strings as commonStrings } from '../lang/common' @@ -15,6 +15,7 @@ function Search({ onSubmit }: SearchProps) { const [keyword, setKeyword] = useState('') + const inputRef = useRef(null) const handleSearchChange = (e: React.ChangeEvent) => { setKeyword(e.target.value) @@ -39,6 +40,7 @@ function Search({
{ setKeyword('') + inputRef.current?.focus() }} > diff --git a/frontend/src/components/BookingFilter.tsx b/frontend/src/components/BookingFilter.tsx index 842afe00..b1ec52fa 100644 --- a/frontend/src/components/BookingFilter.tsx +++ b/frontend/src/components/BookingFilter.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useState, useRef } from 'react' import { FormControl, TextField, @@ -38,6 +38,8 @@ function BookingFilter({ const [keyword, setKeyword] = useState('') const [minDate, setMinDate] = useState() + const inputRef = useRef(null) + const handleSearchChange = (e: React.ChangeEvent) => { setKeyword(e.target.value) } @@ -115,6 +117,7 @@ function BookingFilter({ { setKeyword('') + inputRef.current?.focus() }} >