fix(theme): keep facet selections in the URL - #3471
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jssaid 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 asex_q.What changes
search.js:syncStartParam()becomessyncUrlParams()and writes the facet selections asex_qclauses besidesstart=, in place (replaceState), as the page offset already was. A facet click still does not add a history entry.runFromUrl()sorts the URL'sex_qclauses 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.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 resettingstart=now expects theex_qit adds.The theme version stays 1.3.0: it was set for 15.9 and has not been released yet.
Verification
src/test/js,npx vitest run): 577 passed. The five new or changed cases fail on main.mvn test -Dtest=BundledBootstrapThemeTest: 125 tests passed./search?q=facetword, 4 hits/search?q=facetword&ex_q=label%3Ateamdocs, 4 hitsex_qex_q=label:teamdocs