fix(theme/bootstrap): reset in-memory facet state on navigation#3173
Closed
marevol wants to merge 1 commit into
Closed
fix(theme/bootstrap): reset in-memory facet state on navigation#3173marevol wants to merge 1 commit into
marevol wants to merge 1 commit into
Conversation
The bootstrap SPA search theme keeps filter state in two in-memory stores: - state.facets: written only by sidebar facet clicks, which call runSearch() directly and never serialize the selection to the URL. - state.fields: written by the search-options label dropdown and serialized to the URL as fields.*. runSearch() merges both stores into the request. runFromUrl() re-derives state from the URL on every navigation but did not reset the memory-only stores, so a label chosen via the facet sidebar survived a later search-options submit: the URL carried only the new label, yet the stale facet label was merged back in, applying both labels and showing both as active-filter chips. Reset state.facets, state.facetQueries and state.sdh in runFromUrl() so the URL is the single source of truth on every navigation. The same reset already ships in the derived SPA themes in codelibs/fess-themes; this aligns the canonical bootstrap theme in core. The filter-only-search behavior added in #3171 is preserved (the empty-keyword guard is left intact).
Contributor
Author
|
Closing as redundant. The facet-state reset this PR adds already landed in master via #3170, which resets |
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.
Problem
In the bootstrap SPA 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:
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 callrunSearch()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 onlyreset
state.fields/lang/geo/exQ, leavingstate.facets,state.facetQueriesand the similar-docs hash (state.sdh) intact. Thesearch-options submit navigates with only
fields.*in the URL, so the stalestate.facetssurvived andrunSearch()merged both stores together.Fix
Reset
state.facets,state.facetQueriesandstate.sdhinrunFromUrl()sothe 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 persistswithin the same result view as before.
The same reset already ships in the derived SPA themes in
codelibs/fess-themes;this aligns the canonical bootstrap theme in core. The filter-only-search
behavior added in #3171 is preserved — only the three memory-only stores are
reset, and the empty-keyword guard logic is left intact.
Testing
node --checkon the modified file passes.search.js(facet click handler, search-optionssubmit handler,
runFromUrl, therunSearchfield merge, and pagination).Confirmed the stale stores are cleared on navigation and that paging/facet
interactions are unaffected because they do not navigate.
Supersedes #3170, which was branched before #3171 and would otherwise revert
that change.