Commit 3237bcb7 authored by Yuri Mikhin's avatar Yuri Mikhin Committed by Yuri Mikhin

Fix clear button condition in FilterInput.

parent b6f55cae
...@@ -15,6 +15,7 @@ type Props = { ...@@ -15,6 +15,7 @@ type Props = {
const FilterInput = ({ onChange, className, size = 'sm', placeholder }: Props) => { const FilterInput = ({ onChange, className, size = 'sm', placeholder }: Props) => {
const [ filterQuery, setFilterQuery ] = useState(''); const [ filterQuery, setFilterQuery ] = useState('');
const inputRef = React.useRef<HTMLInputElement>(null); const inputRef = React.useRef<HTMLInputElement>(null);
const iconColor = useColorModeValue('blackAlpha.600', 'whiteAlpha.600');
const handleFilterQueryChange = useCallback((event: ChangeEvent<HTMLInputElement>) => { const handleFilterQueryChange = useCallback((event: ChangeEvent<HTMLInputElement>) => {
const { value } = event.target; const { value } = event.target;
...@@ -37,7 +38,7 @@ const FilterInput = ({ onChange, className, size = 'sm', placeholder }: Props) = ...@@ -37,7 +38,7 @@ const FilterInput = ({ onChange, className, size = 'sm', placeholder }: Props) =
<InputLeftElement <InputLeftElement
pointerEvents="none" pointerEvents="none"
> >
<Icon as={ searchIcon } color={ useColorModeValue('blackAlpha.600', 'whiteAlpha.600') }/> <Icon as={ searchIcon } color={ iconColor }/>
</InputLeftElement> </InputLeftElement>
<Input <Input
...@@ -50,18 +51,20 @@ const FilterInput = ({ onChange, className, size = 'sm', placeholder }: Props) = ...@@ -50,18 +51,20 @@ const FilterInput = ({ onChange, className, size = 'sm', placeholder }: Props) =
textOverflow="ellipsis" textOverflow="ellipsis"
/> />
<InputRightElement> { filterQuery ? (
<IconButton <InputRightElement>
colorScheme="gray" <IconButton
aria-label="Clear the filter input" colorScheme="gray"
title="Clear the filter input" aria-label="Clear the filter input"
w={ 6 } title="Clear the filter input"
h={ 6 } w={ 6 }
icon={ <Icon as={ crossIcon } w={ 4 } h={ 4 } color={ useColorModeValue('blackAlpha.600', 'whiteAlpha.600') }/> } h={ 6 }
size="sm" icon={ <Icon as={ crossIcon } w={ 4 } h={ 4 } color={ iconColor }/> }
onClick={ handleFilterQueryClear } size="sm"
/> onClick={ handleFilterQueryClear }
</InputRightElement> />
</InputRightElement>
) : null }
</InputGroup> </InputGroup>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment