|
|
5 days ago | |
|---|---|---|
| js | 5 days ago | |
| README.md | 5 days ago | |
| preserve_advanced_search.info.yml | 5 days ago | |
| preserve_advanced_search.libraries.yml | 5 days ago | |
| preserve_advanced_search.module | 5 days ago | |
README.md
Preserve Advanced Search
Keeps the advanced search a[] query parameters attached to the facet slider
URLs that Facets builds server-side, so clicking a slider doesn't drop the
user's advanced search criteria.
Replaces the equivalent code that previously lived in individual themes
(THEME.libraries.yml + THEME_preprocess_page()).
Install
Copy this directory to web/modules/custom/preserve_advanced_search on each
site, then:
drush en preserve_advanced_search
drush cr
Scope
hook_library_info_alter() appends this module's library to the dependencies of
facets_range_nouislider/facets_range_nouislider. It therefore loads only on
pages that actually render a noUiSlider facet — not site-wide, and with no route
list to maintain per site.
Library info is cached, so run drush cr after deploying or the alter won't
take effect.
If a site configures its facets with the Facets core slider widget
(facets_range_widget) instead of facets_range_nouislider, add that
extension's library to the alter as well. Both submodules write to
drupalSettings.facets.sliders, so the JavaScript itself needs no change — only
the attachment point does.
Notes
- Load order is guaranteed by the dependency: our script is loaded ahead of
slider.js, soDrupal.behaviors.preserveAdvancedSearchParamsis registered first and runs first.facets_range_nouislider'sslider.jsis additionally markeddefer: truewhile ours is not, and non-deferred scripts always execute before deferred ones — so the ordering holds twice over. rebuildUrl()is idempotent (it strips alla[]params before re-adding the current ones), so re-running on AJAX rebuilds is safe.- The JS handles both
sliderSettings.urlandsliderSettings.urls. Range widgets collapse the parent'surlsmap into a singleurl(RangeNoUiSliderWidget::build()); single-handle widgets keepurls. Both branches are live — don't remove either.