Preserves the advanced search query parameters when using both the advanced search module and the nouislider module.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Paul Pound d2d9b56200 initial commit 5 days ago
js initial commit 5 days ago
README.md initial commit 5 days ago
preserve_advanced_search.info.yml initial commit 5 days ago
preserve_advanced_search.libraries.yml initial commit 5 days ago
preserve_advanced_search.module initial commit 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, 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.