# 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 composer require roblib/preserve_advanced_search drush en preserve_advanced_search drush cr Or copy this directory to `web/modules/custom/preserve_advanced_search` and enable it as above. ## 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`, so `Drupal.behaviors.preserveAdvancedSearchParams` is registered first and runs first. `facets_range_nouislider`'s `slider.js` is additionally marked `defer: true` while ours is not, and non-deferred scripts always execute before deferred ones — so the ordering holds twice over. - `rebuildUrl()` is idempotent (it strips all `a[]` params before re-adding the current ones), so re-running on AJAX rebuilds is safe. - The JS handles both `sliderSettings.url` and `sliderSettings.urls`. Range widgets collapse the parent's `urls` map into a single `url` (`RangeNoUiSliderWidget::build()`); single-handle widgets keep `urls`. Both branches are live — don't remove either.