roblib / preserve_advanced_search
Keeps advanced search a[] query parameters attached to facet slider URLs built by the server.
Package info
git.library.upei.ca/Code/preserve_advanced_search
Type:drupal-module
pkg:composer/roblib/preserve_advanced_search
Requires
- php: >=8.1
- drupal/core: ^10 || ^11
Suggests
- drupal/facets: Provides the facets_range_nouislider submodule whose library this module alters.
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, 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.