Skip to content

Conversation

@lordvkrum
Copy link
Contributor

  • Add advancedParameters fetchZeroStateOnFocus to override the zero state fetching behavior from initial render to input focus

@lordvkrum lordvkrum requested a review from a team May 10, 2024 16:10
const [podsData, setPodsData] = useState<Record<string, PodData>>({});

useEffect(() => {
const fetchRecommendationResults = async () => {
Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor

@mocca102 mocca102 May 29, 2024

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.

Copy link
Contributor

@mocca102 mocca102 left a 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]);
Copy link
Contributor

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

@mocca102 mocca102 requested a review from a team May 31, 2024 11:37
Copy link
Contributor

@esezen esezen left a comment

Choose a reason for hiding this comment

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

LGTM!

@esezen esezen merged commit bd1dffd into main Jun 27, 2024
@esezen esezen deleted the ci-3436-autocomplete-ui-add-an-option-to-call-zero-state-requests-on branch June 27, 2024 11:54
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.

4 participants