-
Notifications
You must be signed in to change notification settings - Fork 683
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
[bugfix] Hide stale suggestions #2150
Conversation
|
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.
Good improvement, always thought that was just want UX wanted 😂 A few tiny things to clean up and this is good to go.
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.
LGTM 👍
@jimbo I can still reproduce the issue in one case - Enter "Tops Dress" > Wait for suggestions and delete the entire input via delete key. Now click outside the textfield and click back in. Search suggestions are shown for "Tops" |
Looked at this with Dev; looks like its easiest to reproduce by holding down backspace to remove the search value. |
This is so bizarre. I can replicate this with |
|
||
// run the query once on mount, and again whenever state changes | ||
useEffect(() => { | ||
if (visible && valid) { | ||
debouncedRunQuery({ variables: { inputText: value } }); | ||
} else if (called && !value && !visible) { | ||
setCleared(true); |
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.
What's happening is that as you delete the text of tops dresses
the last "valid" search text is top
which is used as the debounced query. That explains why you see product suggestions for top
which are based on the last search data, but you don't see any text in the <input> in <Category>
suggestions.
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.
I fixed this by moving the setCleared
logic into the debounced run query. The last call that executes should control the UI. In this case, we don't need to validate input before the debounce, we can do that inside the debounce, and if it is invalid we just clear the view.
Signed-off-by: Stephen Rugh <[email protected]>
@dpatil-magento I think this is fixed. |
After clearing if I click back > stale results display for fraction of second and goes away. |
@dpatil-magento I've fixed that issue. Please give it another test. Important: we had logic that was reading the value of |
const debouncedRunQuery = useMemo( | ||
() => | ||
debounce(inputText => { | ||
runQuery({ variables: { inputText } }); |
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.
This now runs with the last 3 characters in the input when you start deleting some text value. For example "top shirt" will search "top shirt" but when you delete that character by character it'll query for "top" since it is the last valid value on the way to an empty string. Note that unlike the earlier bug it won't display the results because the display state of the results is based on the validity of the current input, not the last searched input.
I would prefer we don't make an extra call for text that may never be searched but it's also a minor optimization so 🤷
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.
+1+1+1+1
@jimbo Looks good but still there is minor issue. Input |
That's fine. We don't have any defined loading behavior yet, so it's going to show stale results while the next query is resolving. |
Description
Fix a bug with
Suggestions
wherein stale results would continue to be displayed when the field had been cleared. The proper fix would entail resetting the query, such thatcalled
would befalse
anddata
would beundefined
, but Apollo does not yet offer that functionality. Instead, this fix recognizes when the field has been cleared and incorporates that into the conditional rendering logic ofAutocomplete
andSuggestions
.This fix involves changes to the talon APIs, so it's probably a major. As a result, I've also taken the opportunity to have
SearchBar
obtainhistory
andlocation
from hook calls rather than render props.Related Issue
PWA-361
Acceptance
Verification Stakeholders
@dpatil-magento
Specification
Verification Steps
athena
in the search input.Screenshots / Screen Captures (if appropriate)
Checklist