-
Notifications
You must be signed in to change notification settings - Fork 30
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(project): update collections search asynchronously #6127
fix(project): update collections search asynchronously #6127
Conversation
485ceef
to
408eb9a
Compare
d229ced
to
5c5e976
Compare
Tune this value to determine when a search term | ||
is long enough to use Panoptes full-text search. | ||
*/ | ||
const MIN_SEARCH_LENGTH = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increasing this might make the search results more intuitive.
a6a4e34
to
7e46e7d
Compare
2342465
to
cd49294
Compare
...oject/src/shared/components/CollectionsModal/components/SelectCollection/SelectCollection.js
Outdated
Show resolved
Hide resolved
cd49294
to
8e1f127
Compare
Make the collections search, in the popup collections modal, asynchronous. This fixes a bug where search results were not correctly synchronised to the stored search term (in component state.)
We don't want the component to rerender when the search text changes, only when new search results are received from Panoptes.
8e1f127
to
be09e4a
Compare
...oject/src/shared/components/CollectionsModal/components/SelectCollection/SelectCollection.js
Outdated
Show resolved
Hide resolved
const search = text.trim() | ||
onSearch({ | ||
await onSearch({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix for the bug is to wait on the API request before updating state.
0863241
to
8a5cdd9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The collections search is working more as expected with these changes 👍 .
The panoptes full-text search yields some unexpected results, as noted in this comment - #6120 (comment) - but that's unrelated to these changes and the specific issue of seeing all the collections with 4 characters.
Thanks for the fix!
Make the collections search, in the popup collections modal, asynchronous by using a ref to store the current search text. This fixes a bug where search results were not correctly synchronised to the stored search term (in component state.)
If you typed 4 characters into the search box, all your collections were shown, because the component didn't wait for new search results before updating the dropdown menu. Now, it waits for new search results from the Panoptes API before updating.
I've also refactored the minimum required search text length (for full-text search) into
MIN_SEARCH_LENGTH
, which makes it easier to manage. 3 is the minimum required by Postgres, but fuzzy text searching can give weird results for 4 or 5-character strings, so increasing it might make the component easier to use. If you increase the value, I'd suggest also increasing the same value in zooniverse/Panoptes-Front-End#7124, so that the search behaviour matches in PFE.Please request review from
@zooniverse/frontend
team or an individual member of that team.Package
Linked Issue and/or Talk Post
How to Review
Open the collections modal and try any search that is exactly 4 characters. The list of collections now only shows results returned from the Panoptes full-text-search API.
Note that the API response can still miss collection names that include the search term.
Screen.Recording.2024-06-10.at.18.10.23.mov
Checklist
PR Creator - Please cater the checklist to fit the review needed for your code changes.
PR Reviewer - Use the checklist during your review. Each point should be checkmarked or discussed before PR approval.
General
yarn panic && yarn bootstrap
ordocker-compose up --build
and FEM works as expectedGeneral UX
Example Staging Project: i-fancy-cats
Bug Fix