diff --git a/src/components/atoms/SearchTextField.tsx b/src/components/atoms/SearchTextField.tsx new file mode 100644 index 00000000..2821c116 --- /dev/null +++ b/src/components/atoms/SearchTextField.tsx @@ -0,0 +1,26 @@ +/* + * Copyright (C) Contributors to the Suwayomi project + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +import TextField from '@mui/material/TextField'; +import { IconButton, InputAdornment, TextFieldProps } from '@mui/material'; +import CancelIcon from '@mui/icons-material/Cancel'; + +export const SearchTextField = ({ onCancel, ...textFieldProps }: TextFieldProps & { onCancel: () => void }) => ( + + onCancel()}> + + + + ), + }} + {...textFieldProps} + /> +); diff --git a/src/components/util/AppbarSearch.tsx b/src/components/util/AppbarSearch.tsx index b16c4234..60d9e4ad 100644 --- a/src/components/util/AppbarSearch.tsx +++ b/src/components/util/AppbarSearch.tsx @@ -8,11 +8,11 @@ import React, { useState, useEffect } from 'react'; import SearchIcon from '@mui/icons-material/Search'; -import { IconButton, Input, Tooltip } from '@mui/material'; -import CancelIcon from '@mui/icons-material/Cancel'; +import { IconButton, Tooltip } from '@mui/material'; import { useQueryParam, StringParam } from 'use-query-params'; import { useTranslation } from 'react-i18next'; import { useLocation, useNavigate } from 'react-router-dom'; +import { SearchTextField } from '@/components/atoms/SearchTextField.tsx'; interface IProps { autoOpen?: boolean; @@ -122,8 +122,10 @@ export const AppbarSearch: React.FunctionComponent = (props) => { if (searchOpen) { return ( - setSearchString(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') { @@ -132,11 +134,6 @@ export const AppbarSearch: React.FunctionComponent = (props) => { }} onBlur={handleBlur} inputRef={inputRef} - endAdornment={ - - - - } /> ); }