fix: keep the search UI when a query matches nothing - #162
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #162 +/- ##
=======================================
Coverage 99.56% 99.56%
=======================================
Files 101 101
Lines 682 683 +1
Branches 168 168
=======================================
+ Hits 679 680 +1
Misses 2 2
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| {searchString && !hasCourses && ( | ||
| <Button variant="link" className="pl-0 mb-3" onClick={() => handleSearch('')}> | ||
| {intl.formatMessage(messages.clearSearch)} | ||
| </Button> | ||
| )} |
There was a problem hiding this comment.
It was there for instances with ENABLE_COURSE_DISCOVERY off (where no search field renders but ?search_query= is still honoured). But yeah, probably too much of an edge case to bother.
|
The "when a query matches nothing" logic is a bit odd, but based on conversations from #42 (comment)
So my understanding is that in the legacy (non-MFE) course catalog the desired outcome of searching for something that has 0 results is to show the entire first page of the catalog. The actual "Clicking back to an empty search dead end's with an incorrect error" part of the issue is 100% a bug we should fix, but changing the behavior of "I searched for something that has 0 results" seems like a product call. |
That is not how any search box I've ever seen behaves (to the extent I thought it was a bug), but... Who am I to judge. 🤷🏼♂️ I'll roll it back. |
It definitely stood out as strange to me too (hence the comments on the linked PR), but that was backed by "match legacy behavior." I do think it's worth raising as a product issue. I'd be happy to have a more standard experience. |
Landing on a search with no results replaced the controls with the empty-catalog alert, leaving no way back to the catalog. Closes openedx#161 Co-Authored-By: Claude <noreply@anthropic.com>
fceb834 to
1fe607d
Compare

Description
Returning to a search that matched nothing, or landing on a
?search_query=URL directly, replaced the search and filter controls with the "No courses available" alert, which is the empty-catalog message. With nothing left to click, the only way out was the top nav.The controls now stay whenever a search is active, so an empty result set reads as an answer to the query rather than as an empty catalog.
DataTablealready carries the right empty state for that case. What a zero-result search displays is unchanged.Fixes #161. The end-to-end tests disabled in openedx/end-to-end-tests#28 can be re-enabled.
LLM usage notice
Built with assistance from Claude.