Skip to content

Commit

Permalink
Fixed showing empty input error message on pressing Search button/ (#400
Browse files Browse the repository at this point in the history
)

- App was not showing "Search bar is Empty..." error message when user perform search on slang which is not present in database and user clear the input box and press Search button.
  • Loading branch information
miteshsavani authored Jan 11, 2024
1 parent 03a5f63 commit 5abc800
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/components/form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Form = () => {
const [error, setError] = useState(false);
const [errorMessage, setErrorMessage] = useState(false);
const [userInput, setUserInput] = useState("");
const [isUserInputBlank, setIsUserInputBlank] = useState(true);
const [isUserInputBlank, setIsUserInputBlank] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const previousUserInput = useRef(undefined);
const hasUserInputChanged = previousUserInput.current !== userInput;
Expand Down Expand Up @@ -63,8 +63,6 @@ const Form = () => {
if (!isUserInputBlank) {
previousUserInput.current = userInput;
}

clearDataBeforeFetch();
}, [userInput]);

return (
Expand Down Expand Up @@ -107,9 +105,10 @@ const Form = () => {
placeholder="Search slang full meaning..."
className="flex-1 w-[14rem] h-6 ml-2 border-none outline-none placeholder:text-black bg-ash"
value={userInput}
onChange={(e) =>
setUserInput(e.target.value.toLocaleLowerCase())
}
onChange={(e) => {
clearDataBeforeFetch();
setUserInput(e.target.value.toLocaleLowerCase());
}}
/>
</div>

Expand Down

1 comment on commit 5abc800

@vercel
Copy link

@vercel vercel bot commented on 5abc800 Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.