Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/Mobile search #4868

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 39 additions & 26 deletions src/components/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,49 @@ export const SearchInput: FC<ISearchInputProps> = ({ setTerm, className }) => {
setValue(event.target.value);
}

function handleFormSubmit(inputValue: string) {
if (inputValue.length > 2) {
setTerm(inputValue);
}
}

const [inputRef] = useFocus();

return (
<SearchInputContainer className={className}>
<InputContainer onKeyDown={handleKeyDown}>
<StyledInput
onChange={handleOnChange}
as='input'
placeholder={formatMessage({
id: 'label.search_for_project',
})}
$baseTheme={theme}
value={value}
ref={inputRef}
/>
{value.length > 0 ? (
<IconRemoveWrapper
onClick={() => {
setValue('');
setTerm('');
}}
>
<IconX24 />
</IconRemoveWrapper>
) : (
<IconWrapper>
<IconSearch24 />
</IconWrapper>
)}
</InputContainer>
<form
onSubmit={e => {
e.preventDefault();
handleFormSubmit(value);
}}
>
<InputContainer onKeyDown={handleKeyDown}>
<StyledInput
onChange={handleOnChange}
as='input'
placeholder={formatMessage({
id: 'label.search_for_project',
})}
$baseTheme={theme}
value={value}
ref={inputRef}
/>
kkatusic marked this conversation as resolved.
Show resolved Hide resolved
{value.length > 0 ? (
<IconRemoveWrapper
onClick={() => {
setValue('');
setTerm('');
}}
>
kkatusic marked this conversation as resolved.
Show resolved Hide resolved
<IconX24 />
</IconRemoveWrapper>
) : (
<IconWrapper>
<IconSearch24 />
</IconWrapper>
)}
</InputContainer>
</form>
<HintRow $baseTheme={theme}>
{value.length > 0 ? (
value.length > 2 ? (
Expand Down
Loading