[Test failure] <TC-00065>: Course search pill not cleared when text deleted
Release
Ulmo
Expected behavior
I am able to clear my search by clicking X on the pill with my search term on it that appears under the search bar OR by deleting the search term in the search bar and clicking search or hitting enter
When i delete the search term in the search bar and click search, the search term under the bar (with the X) should disappear
Actual behavior
Pill with search term under the bar remains even when search bar text is cleared & all courses are returned
search results:
after deleting search bar text:
Steps to reproduce
- Go to https://ulmo.demo.edly.io/courses
- Type 'test' in search bar and hit enter
- Delete 'test' from search bar and hit enter
- See 'test' box still under search bar even though all 14 results are being shown
Additional information
No response
Hello @saraburns1, thanks!
I was testing in the sandbox, and the reported issue is indeed happening. I also tested in a Redwood and Teak environment, and the same thing occurs.
Although the filter in the search does get cleared and works correctly, the pill with the old term still appears, which is confusing. A simple solution is to remove that filter when the search is performed if the input is empty.
I tested something like this locally, and it works well:
dispatcher.listenTo(form, 'search', function(query) {
form.showLoadingIndicator();
if (!query || query.trim() === '') {
filters.remove('search_query');
}
search.performSearch(query, filters.getTerms());
});
https://github.com/user-attachments/assets/d935cb94-1daa-4dc3-9683-4a87a51ac127
The suggested solution is ready to review in this PR: https://github.com/openedx/edx-platform/pull/37709
The original PR was merged into master and I opened a backport for ulmo here: https://github.com/openedx/edx-platform/pull/37734
cc: @magajh
The backport for ulmo was merged