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

Preventing seeing no posts when clicking on the "Search" button while search inputs are empty #114

Open
wants to merge 1 commit into
base: PART_4
Choose a base branch
from

Conversation

MatinT-SA
Copy link

@MatinT-SA MatinT-SA commented Apr 16, 2022

I realized that when you click on the "Search" button and both "tags" & "search" inputs are empty, then it's going to show you the loading icon and return an empty array which is not the expected output.
This means it's still going to run the if block of code (if you pay attention to the url) while the else block must be executed instead of that.

It means we should change our conditions and just add length at the end of the search.trim() & tags so as to count the number of items in our array.
This will produce the ideal and expected output and it will run the else block while we have written nothing in the search inputs and have also clicked on the search button instead of seeing no posts on the screen. So, it means it's going to redirect the user to the home page (history.push('/')) if we only click on the "Search" button without writing anything in its inputs.

@MatinT-SA MatinT-SA changed the title Preventing to see no posts when clicking on the "Search" button while search inputs are empty Preventing seeing no posts when clicking on the "Search" button while search inputs are empty Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant