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,6 +51,7 @@ const FilterInput = ({ onChange, className, size = 'sm', placeholder }: Props) = ...@@ -50,6 +51,7 @@ const FilterInput = ({ onChange, className, size = 'sm', placeholder }: Props) =
textOverflow="ellipsis" textOverflow="ellipsis"
/> />
{ filterQuery ? (
<InputRightElement> <InputRightElement>
<IconButton <IconButton
colorScheme="gray" colorScheme="gray"
...@@ -57,11 +59,12 @@ const FilterInput = ({ onChange, className, size = 'sm', placeholder }: Props) = ...@@ -57,11 +59,12 @@ const FilterInput = ({ onChange, className, size = 'sm', placeholder }: Props) =
title="Clear the filter input" title="Clear the filter input"
w={ 6 } w={ 6 }
h={ 6 } h={ 6 }
icon={ <Icon as={ crossIcon } w={ 4 } h={ 4 } color={ useColorModeValue('blackAlpha.600', 'whiteAlpha.600') }/> } icon={ <Icon as={ crossIcon } w={ 4 } h={ 4 } color={ iconColor }/> }
size="sm" size="sm"
onClick={ handleFilterQueryClear } 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