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

Fixes: #2062: Search bar fires a request on every entered letter #2066

Merged
merged 1 commit into from
Apr 7, 2021
Merged

Fixes: #2062: Search bar fires a request on every entered letter #2066

merged 1 commit into from
Apr 7, 2021

Conversation

HyperTHD
Copy link
Contributor

@HyperTHD HyperTHD commented Apr 1, 2021

Issue This PR Addresses

Fixes #2062

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

I landed #2046 to create a search context. There was a bug I didn't catch where it would create a request on every entered letter instead of just waiting until the user press the enter key or clicks the search button.

I included the textParam as a value in the SearchProvider which will ensure that SearchResults.tsx uses that property instead of text. Since the text value gets updated everytime a letter is entered, it would fire the async request to search for a post.

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

Copy link
Contributor

@PedroFonsecaDEV PedroFonsecaDEV left a comment

Choose a reason for hiding this comment

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

Go to search and open the network tab. You will notice that you are firing requests even without typing.
This is another bug that we already fixed a long time ago.

@HyperTHD HyperTHD requested a review from PedroFonsecaDEV April 1, 2021 17:39
@birtony
Copy link
Contributor

birtony commented Apr 1, 2021

🤔
image

@HyperTHD
Copy link
Contributor Author

HyperTHD commented Apr 2, 2021

🤔
image

That's really weird. The search bar should be calling the search service instead of the posts service anyway so that's not the intended behaviour and is unrelated to this PR. That said, your image is indicating that the posts service was unable to find the post instead of showing the search query server error message which is weird

humphd
humphd previously approved these changes Apr 2, 2021
birtony
birtony previously approved these changes Apr 3, 2021
Copy link
Member

@manekenpix manekenpix left a comment

Choose a reason for hiding this comment

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

I'm seeing what @PedroFonsecaDEV mentioned in his comment before. It seems that the page keeps sending requests infinitely after hitting enter. We had this bug before, but we fixed it. Maybe it's possible to check the history to see how we fixed it.

cc @humphd @birtony

@chrispinkney
Copy link
Contributor

I'm seeing the same requests happening several times over and over again, for example (searched for React):

image

@HyperTHD
Copy link
Contributor Author

HyperTHD commented Apr 3, 2021

I'm seeing the same requests happening several times over and over again, for example (searched for React):

image

That's a bug with the wrong service being used. That's unrelated to this PR

@humphd
Copy link
Contributor

humphd commented Apr 3, 2021

I think the Vercel search issue is related to staging/dev running the back-end on the same origin, so /post:id works there, but breaks on Vercel. Microservices are meant to help with this. See #2012, but we're kind of blocked on other services landing (cc @izhuravlev for Search).

@HyperTHD
Copy link
Contributor Author

HyperTHD commented Apr 4, 2021

Tested #2075 and the search page was working fine. Gonna wait for that to be merged in so I can rebase that in here and see if that does the trick

@PedroFonsecaDEV
Copy link
Contributor

PedroFonsecaDEV commented Apr 4, 2021

@HyperTHD don't rebase using GitHub. Merge in your local machine then push the rebase version.

git checkout master
git pull upstream master
git checkout SearchBugFix
git rebase master

humphd
humphd previously approved these changes Apr 6, 2021
Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

Works great.

humphd
humphd previously approved these changes Apr 7, 2021
manekenpix
manekenpix previously approved these changes Apr 7, 2021
@HyperTHD HyperTHD dismissed stale reviews from manekenpix and humphd via e85a717 April 7, 2021 02:45
@HyperTHD HyperTHD merged commit 1f7dbd9 into Seneca-CDOT:master Apr 7, 2021
@HyperTHD HyperTHD deleted the SearchBugFix branch April 23, 2021 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search component fires a request after every keystroke
6 participants