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

Search bar query #254

Merged
merged 6 commits into from
Jan 16, 2024
Merged
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
13 changes: 6 additions & 7 deletions components/searchBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@

function handleInput(event: FormEvent) {
setQuery((event.target as HTMLInputElement).value);

// When input value is null, set error & empty state to `true` and do nothing.

if (!smallScreen)
debounce(() => {
router.push(`/search?q=${(event.target as HTMLInputElement).value}`);
});
if (!(event.target as HTMLInputElement).value) {
setIsEmpty(true);
setIsError(true);
Expand All @@ -49,12 +53,7 @@
// When input value is not null, reset error & empty state to `false`.
// And also debounce the router push.
setIsError(false);
setIsEmpty(false);

if (!smallScreen)
debounce(() => {
router.push(`/search?q=${(event.target as HTMLInputElement).value}`);
});
setIsEmpty(false);

Check warning on line 56 in components/searchBar/index.tsx

View workflow job for this annotation

GitHub Actions / tsc and eslint

Delete `··`
}

function handleSubmit(event?: FormEvent) {
Expand Down