Skip to content

fix(theme): keep facet selections in the URL - #3471

Merged
marevol merged 1 commit into
mainfrom
fix/theme-facets-159
Sep 23, 2026
Merged

marevol merged 1 commit into
mainfrom
fix/theme-facets-159

Conversation

@marevol

@marevol marevol commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Why

With the bootstrap static theme as the default search UI, facet selections (the label facet and the facet query views such as date, size and file type) were kept only in memory; search.js said so explicitly ("facet selections stay in memory"). After narrowing a search with a facet, the address bar still showed the unfiltered search, so a reload, a link sent to a colleague, or Back from a result document dropped the filter and showed unfiltered results. The JSP search pages put the selections in the URL as ex_q.

What changes

  • search.js:
    • syncStartParam() becomes syncUrlParams() and writes the facet selections as ex_q clauses besides start=, in place (replaceState), as the page offset already was. A facet click still does not add a history entry.
    • runFromUrl() sorts the URL's ex_q clauses back into the stores the facet groups read: label:<value> into the label facet, values of the configured facet query views into those views, and anything else (e.g. from advanced search) into the pass-through list as before. A repeated clause is sent once. Restored selections render active, and a click removes them from the request and the URL.
    • The request is built from the same list (exQClauses()), so the URL and the request cannot drift apart.
  • search.test.js: tests for writing, restoring, deselecting and de-duplicating; the existing test for a facet click resetting start= now expects the ex_q it adds.

The theme version stays 1.3.0: it was set for 15.9 and has not been released yet.

Verification

  • Theme JS tests (src/test/js, npx vitest run): 577 passed. The five new or changed cases fail on main.
  • mvn test -Dtest=BundledBootstrapThemeTest: 125 tests passed.
  • Headless Chromium against a distribution built with this change, OpenSearch 3.8, 12 documents of which 4 carry the label "Team Docs"; search, click the label facet, reload. Before (main) → after:
Step Before After
After the facet click URL /search?q=facetword, 4 hits URL /search?q=facetword&ex_q=label%3Ateamdocs, 4 hits
After reload 10 hits (of 12), no active facet, request without ex_q 4 hits, "Team Docs" active, request with ex_q=label:teamdocs

Facet selections in the bootstrap static theme (label facets and the
facet query views such as file type, size and date) lived only in memory.
After narrowing a search with a facet, a reload, a shared link, or Back
from a result document dropped the filter and showed unfiltered results.
The JSP search pages put the selections in the URL as ex_q.

Write the facet selections to the address bar as ex_q clauses whenever a
search runs (in place, as the page offset already is), and have
runFromUrl() sort the URL's ex_q clauses back into the facet stores, so
the restored selections render active and a click removes them. Clauses
that are not facet selections (e.g. from advanced search) are kept as
before.
@marevol marevol added this to the 15.9.0 milestone Sep 23, 2026
@marevol marevol self-assigned this Sep 23, 2026
@marevol
marevol merged commit c1f2996 into main Sep 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant