Skip to content

fix: top bar search resets state instead of refining#417

Open
saivats wants to merge 4 commits into
openfoodfacts:mainfrom
saivats:fix/top-bar-search-resets-state
Open

fix: top bar search resets state instead of refining#417
saivats wants to merge 4 commits into
openfoodfacts:mainfrom
saivats:fix/top-bar-search-resets-state

Conversation

@saivats

@saivats saivats commented May 26, 2026

Copy link
Copy Markdown

What

Root cause

In submitSuggestion() in search-bar.ts, the non-suggestion path
(plain text + Enter) only set this.query and called this.search().
But buildParams() was still including old facet filters via
_facetsFilters(), appending them to the new query and causing the
combined search and backend 500 error.

Fix

Added this.resetFacets(false) before setting the new query in the
else branch of submitSuggestion(). This reuses the existing
resetFacets() method already used by the Reset button.

Testing

  • Added a test in search-bar_test.ts verifying resetFacets is
    called when user submits plain text search
  • Manually verified: searching "categories:teas" then "categories:pastas"
    now returns only pasta results

@saivats

saivats commented May 26, 2026

Copy link
Copy Markdown
Author

@alexgarel @teolemon — fix for #306 is ready for review.
1 line change in submitSuggestion() + a test. All 24 tests pass.

Comment thread frontend/src/test/search-bar_test.ts
Comment thread frontend/src/test/search-bar_test.ts
Comment thread frontend/src/test/search-bar_test.ts
@alexgarel

Copy link
Copy Markdown
Member

@saivats great, I'll validate my suggestion, it's better to have more comments! But I will then validate
Thank you for this valuable contribution

@github-project-automation github-project-automation Bot moved this from Backlog (ready for dev) to In Progress in 🔎 Search-a-licious Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Search in top bar should start a new search

2 participants