Skip to content

fix: keep the search UI when a query matches nothing - #162

Open
arbrandes wants to merge 1 commit into
openedx:masterfrom
arbrandes:arbrandes/issue-161-empty-search-dead-end
Open

fix: keep the search UI when a query matches nothing#162
arbrandes wants to merge 1 commit into
openedx:masterfrom
arbrandes:arbrandes/issue-161-empty-search-dead-end

Conversation

@arbrandes

@arbrandes arbrandes commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

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. DataTable already 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.

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.56%. Comparing base (0c6f9ec) to head (1fe607d).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/catalog/CatalogPage.tsx Outdated
Comment on lines +108 to +112
{searchString && !hasCourses && (
<Button variant="link" className="pl-0 mb-3" onClick={() => handleSearch('')}>
{intl.formatMessage(messages.clearSearch)}
</Button>
)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this being added? SearchField has a built in "X" to clear.

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@brian-smith-tcril

Copy link
Copy Markdown
Contributor

The "when a query matches nothing" logic is a bit odd, but based on conversations from #42 (comment)

This logic was there to match the behavior in the legacy version.

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.

@arbrandes

Copy link
Copy Markdown
Contributor Author

the desired outcome of searching for something that has 0 results is to show the entire first page of the catalog.

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.

@brian-smith-tcril

Copy link
Copy Markdown
Contributor

the desired outcome of searching for something that has 0 results is to show the entire first page of the catalog.

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>
@arbrandes
arbrandes force-pushed the arbrandes/issue-161-empty-search-dead-end branch from fceb834 to 1fe607d Compare September 2, 2026 19:28
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.

Bug: Clicking back to an empty search dead end's with an incorrect error

2 participants