-
Notifications
You must be signed in to change notification settings - Fork 3
Remove "Top picks" carousel if no results #1195
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
Conversation
| const config = TopPicksCarouselConfig(profile) | ||
| const { data, isLoading } = useLearningResourcesSearch( | ||
| config[0].data | ||
| .params as LearningResourcesSearchApiLearningResourcesSearchRetrieveRequest, |
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.
Do we have a shorter equivalent?
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.
No 😭
I import LearningResourcesSearchApiLearningResourcesSearchRetrieveRequest as SearchRequest sometimes.
a8204de to
18a77a8
Compare
ChristopherChudzicki
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.
Discussed w/ Jon in Slack: Carousel tabs should be visible while carousel is loading, else it looks weird
tabs_video.mov
I've pushed the fix. The inverse isn't ideal either, though certainly the lesser evil if we assume there will generally be content. Screen.Recording.2024-07-09.at.19.14.47.mov |
* Top pick carousel display only if results * Remove not in document test - unreliable * Not used anywhere * Filter carousels without results * Update tests to reflect load states * More specific 'any' and reasoning * Set count in tests * Wait for all tabs to have loaded before removing if empty (fix layout flash) * Remove loading logic on lr_featured tabs
What are the relevant tickets?
Closes https://github.com/mitodl/hq/issues/4711
Description (What does it do?)
Removes the "Top picks for you" if there are no results from the search.
Update: This change now applies the logic to all carousels.
How can this be tested?
Navigate to Dashboard from the user menu or at /dashboard. Testable only by mocking the
/api/v1/learning_resources_searchresponse or overwriting in the code.Additional Context
This will render the loading state first, then removes if no results, expecting that there will normally be results.
I attempted a test to check that the section is not in the document, though found it unreliable to use
waitForElementToBeRemoved()as that depends on the element always being there first. Also got unexpected results checking for the second render cycle (ie.isLoadingnowfalse) by check and then callingwaitForElementToBeRemoved()orexpect(queryByText("Top picks for you")).not.toBeInTheDocument(). Info here, open to suggestions.If we need this in other places we may want to build this into the
ResourceCarouselitself, or provide a carousel+container wrapper in theDashboardPageso we don't need to duplicate theuseLearningResourcesSearch()call.