Skip to content

fix: reset in-memory facet state on navigation in the bootstrap theme#3170

Merged
marevol merged 2 commits into
masterfrom
fix/bootstrap-theme-facet-state-reset
Jun 22, 2026
Merged

fix: reset in-memory facet state on navigation in the bootstrap theme#3170
marevol merged 2 commits into
masterfrom
fix/bootstrap-theme-facet-state-reset

Conversation

@marevol

@marevol marevol commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Problem

In the bootstrap search theme, selecting a label via the sidebar facet and then
refining the search through the search-options panel keeps the previously
selected facet applied, even though it is no longer part of the new selection.

Steps to reproduce:

  1. Search for a term that has more than one label facet.
  2. Click a label in the sidebar facet (label A) → results filtered to A.
  3. Open the search-options panel and select only a different label (label B).
  4. Submit.
  • Expected: only label B is applied.
  • Actual: both label A and label B are applied. The active-filter chips show
    both and the result count reflects both labels, even though the URL only
    contains fields.label=B.

Root cause

Filter state is kept client-side in two stores:

  • state.facets — written only by sidebar facet clicks. Facet clicks call
    runSearch() directly, so the selection is never serialized to the URL.
  • state.fields — written by the search-options label dropdown.

runFromUrl() re-derives state from the URL on every navigation, but it only
reset state.fields / lang / geo / exQ, leaving state.facets and
state.facetQueries intact. The search-options submit navigates with only
fields.* in the URL, so the stale state.facets survived and runSearch()
merged both stores together.

Fix

Reset state.facets and state.facetQueries in runFromUrl() so the URL is
the single source of truth on every navigation (search-options submit, header
search, browser back/forward). Paging and facet clicks call runSearch()
directly without navigating, so an active facet still persists within the same
result view as before.

Testing

Traced the control flow in search.js (facet click handler, search-options
submit handler, runFromUrl, the runSearch field merge, and pagination).
Confirmed the stale store is cleared on navigation and that paging/facet
interactions are unaffected because they do not navigate.

marevol added 2 commits June 22, 2026 22:30
The bootstrap search theme keeps filter state client-side in two stores:
state.facets (written by sidebar facet clicks) and state.fields (written by the
search-options label dropdown). Sidebar facet clicks only mutate state.facets
and call runSearch() directly, so the selection is never written to the URL.

runFromUrl() re-derives filter state from the URL on every navigation but only
reset state.fields/lang/geo/exQ, leaving state.facets and state.facetQueries
untouched. As a result a previously clicked facet survived a search-options
submit (which navigates with only fields.* in the URL) and was merged back into
the request, applying both the old facet label and the newly selected one.

Clear state.facets and state.facetQueries in runFromUrl() so the URL is the
single source of truth on every navigation (search-options submit, header
search, browser back/forward). Paging and facet clicks call runSearch()
directly without navigating, so an active facet still persists within the same
result view as before.
state.sdh is another memory-only filter that is merged into the search request
but is never written to the URL, so runFromUrl() did not re-derive it. After a
similarity search (clicking a result's "similar documents" link), a subsequent
header search or search-options submit navigated without sdh in the URL, yet
runSearch() re-attached the stale state.sdh and silently kept the old
similarity constraint.

Clear state.sdh in runFromUrl() alongside the facet stores so all memory-only,
URL-less filter state is reset on every navigation. The similar-docs link
handler calls runSearch() directly without navigating, so an active similarity
search still persists within the same result view.
@marevol marevol self-assigned this Jun 22, 2026
@marevol marevol added the task label Jun 22, 2026
@marevol marevol added this to the 15.7.0 milestone Jun 22, 2026
@marevol marevol merged commit ec8f4ca into master Jun 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant