Skip to content

Conversation

@jonkafton
Copy link
Contributor

@jonkafton jonkafton commented Jun 28, 2024

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_search response 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. isLoading now false) by check and then calling waitForElementToBeRemoved() or expect(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 ResourceCarousel itself, or provide a carousel+container wrapper in the DashboardPage so we don't need to duplicate the useLearningResourcesSearch() call.

@jonkafton jonkafton changed the title Remove "top picks for you" carousel if no results. Remove "Top picks" carousel if no results Jun 28, 2024
const config = TopPicksCarouselConfig(profile)
const { data, isLoading } = useLearningResourcesSearch(
config[0].data
.params as LearningResourcesSearchApiLearningResourcesSearchRetrieveRequest,
Copy link
Contributor Author

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?

Copy link
Contributor

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.

@jonkafton jonkafton added the Needs Review An open Pull Request that is ready for review label Jun 28, 2024
@jonkafton jonkafton removed the Needs Review An open Pull Request that is ready for review label Jul 2, 2024
@jonkafton jonkafton marked this pull request as draft July 3, 2024 16:57
@jonkafton jonkafton force-pushed the jk/4711-hide-top-picks branch from a8204de to 18a77a8 Compare July 3, 2024 17:00
@jonkafton jonkafton marked this pull request as ready for review July 8, 2024 20:05
@ChristopherChudzicki ChristopherChudzicki self-assigned this Jul 8, 2024
Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki left a 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

@jonkafton
Copy link
Contributor Author

Discussed w/ Jon in Slack: Carousel tabs should be visible while carousel is loading, else it looks weird

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

@jonkafton jonkafton merged commit bf41718 into main Jul 9, 2024
@odlbot odlbot mentioned this pull request Jul 10, 2024
27 tasks
mbertrand pushed a commit that referenced this pull request Jul 15, 2024
* 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
@rhysyngsun rhysyngsun deleted the jk/4711-hide-top-picks branch February 7, 2025 20:32
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.

3 participants