roblib/preserve_advanced_search

Keeps advanced search a[] query parameters attached to facet slider URLs built by the server.

Maintainers

Package info

git.library.upei.ca/Code/preserve_advanced_search

Issues

Type:drupal-module

pkg:composer/roblib/preserve_advanced_search

Transparency log

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

dev-main 2026-08-27 16:40 UTC

This package is not auto-updated.

Last update: 2026-08-28 15:09:57 UTC


README

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.