-
Notifications
You must be signed in to change notification settings - Fork 3
[CI-3436] Autocomplete UI - Add an option to call zero state requests on focus #141
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
[CI-3436] Autocomplete UI - Add an option to call zero state requests on focus #141
Conversation
lordvkrum
commented
May 10, 2024
- Add advancedParameters fetchZeroStateOnFocus to override the zero state fetching behavior from initial render to input focus
| const [podsData, setPodsData] = useState<Record<string, PodData>>({}); | ||
|
|
||
| useEffect(() => { | ||
| const fetchRecommendationResults = async () => { |
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.
moving function outside useEffect so it can be exported
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 like this! What do you think about moving it outside of useFetchRecommendationPod into utils file. So it can be imported in useCioAutocomplete without having to keep exposing it up across different hooks?
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.
@lordvkrum I checked your POC branch, and I thought of not calling fetchRecommendationResults inside the onFocus callback because of missing dependencies. And depend on the useEffect here to run an effect when the input is focused but there was still complexity with the dependencies. Because of that it's better that we move forward with your current implementation for now.
…l-zero-state-requests-on
…l-zero-state-requests-on
mocca102
left a comment
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 is looking good for the most part. Just left two comments, let me know what you think
| }); | ||
| }; | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, [menuIsOpen, sections]); |
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.
There was a race condition where menuIsOpen=true but the recommendations element was not rendered and the functiontrackRecommendationView was not being called for the first focus but gets fired for subsequent focuses
Adding sections as dependency fixed that but caused multiple trackRecommendationView hence the addition if viewedRecommendations to keep track of when the recommendation has been viewed as long as the menu is open. Once the menu is closed it restrarts
esezen
left a comment
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!