diff --git a/js/preserve-advanced-search.js b/js/preserve-advanced-search.js
new file mode 100644
index 0000000..41dc943
--- /dev/null
+++ b/js/preserve-advanced-search.js
@@ -0,0 +1,69 @@
+(function ($, Drupal, once) {
+ 'use strict';
+
+ Drupal.behaviors.preserveAdvancedSearchParams = {
+ attach: function (context, settings) {
+
+ console.log('preserve-advanced-search.js loaded');
+
+ // Extract a[] params from the current page URL
+ const rawSearch = window.location.search;
+ const aParams = rawSearch
+ .substring(1)
+ .split('&')
+ .filter(part => part.startsWith('a%5B') || part.startsWith('a['))
+ .join('&');
+
+ console.log('[AdvSearch] aParams found:', aParams);
+
+ // Nothing to preserve — bail out
+ if (!aParams) return;
+
+ // Target the
that has data-drupal-facet-id
+ // then find the .facet-slider inside it which is the noUiSlider element
+ once('preserve-advsearch-slider', '[data-drupal-facet-id]', context)
+ .forEach(function (el) {
+ const facetId = el.dataset.drupalFacetId;
+ const sliderEl = el.querySelector('.facet-slider');
+
+ console.log('[AdvSearch] Found facet:', facetId, 'slider el:', sliderEl);
+
+ if (!sliderEl || !sliderEl.noUiSlider) {
+ console.warn('[AdvSearch] No noUiSlider instance found on', sliderEl);
+ return;
+ }
+
+ // Get the facet settings from drupalSettings
+ const facetSettings = settings.facets && settings.facets[facetId];
+ console.log('[AdvSearch] facetSettings:', facetSettings);
+
+ if (!facetSettings) {
+ console.warn('[AdvSearch] No drupalSettings.facets entry for:', facetId);
+ return;
+ }
+
+ // Remove original change listener and replace with patched version
+ sliderEl.noUiSlider.off('change');
+ sliderEl.noUiSlider.on('change', function (values, handle, unencoded) {
+ let newUrl;
+
+ if (facetSettings.range) {
+ newUrl = facetSettings.url
+ .replace('__range_slider_min__', Math.round(unencoded[0]))
+ .replace('__range_slider_max__', Math.round(unencoded[1]));
+ } else {
+ newUrl = facetSettings.urls['f_' + values[0]];
+ }
+
+ console.log('[AdvSearch] Navigating to:', newUrl + '&' + aParams);
+
+ const separator = newUrl.includes('?') ? '&' : '?';
+ window.location.href = newUrl + separator + aParams;
+ });
+
+ console.log('[AdvSearch] Slider change handler patched successfully');
+ });
+ }
+ };
+
+})(jQuery, Drupal, once);
diff --git a/olivesnews-preserve-advanced-search.patch b/olivesnews-preserve-advanced-search.patch
new file mode 100644
index 0000000..87ab085
--- /dev/null
+++ b/olivesnews-preserve-advanced-search.patch
@@ -0,0 +1,29 @@
+diff --git a/olivesnews.libraries.yml b/olivesnews.libraries.yml
+index 75479c7..701e67f 100755
+--- a/olivesnews.libraries.yml
++++ b/olivesnews.libraries.yml
+@@ -73,6 +73,14 @@ nouislider-year-format:
+ dependencies:
+ - core/drupal
+
++preserve-advanced-search:
++ js:
++ js/preserve-advanced-search.js: {}
++ dependencies:
++ - core/drupal
++ - core/once
++ - core/jquery
++
+ book:
+ version: VERSION
+ css:
+diff --git a/olivesnews.theme b/olivesnews.theme
+index e81fa1d..e1ceeaf 100755
+--- a/olivesnews.theme
++++ b/olivesnews.theme
+@@ -747,4 +747,5 @@ function _olivesnews_hex_to_hsl(string $hex_string)
+ function olivesnews_preprocess_page(&$variables)
+ {
+ $variables['#attached']['library'][] = 'olivesnews/nouislider-year-format';
++ $variables['#attached']['library'][] = 'olivesnews/preserve-advanced-search';
+ }
diff --git a/olivesnews.libraries.yml b/olivesnews.libraries.yml
index 75479c7..701e67f 100755
--- a/olivesnews.libraries.yml
+++ b/olivesnews.libraries.yml
@@ -73,6 +73,14 @@ nouislider-year-format:
dependencies:
- core/drupal
+preserve-advanced-search:
+ js:
+ js/preserve-advanced-search.js: {}
+ dependencies:
+ - core/drupal
+ - core/once
+ - core/jquery
+
book:
version: VERSION
css:
diff --git a/olivesnews.theme b/olivesnews.theme
index e81fa1d..e1ceeaf 100755
--- a/olivesnews.theme
+++ b/olivesnews.theme
@@ -747,4 +747,5 @@ function _olivesnews_hex_to_hsl(string $hex_string)
function olivesnews_preprocess_page(&$variables)
{
$variables['#attached']['library'][] = 'olivesnews/nouislider-year-format';
+ $variables['#attached']['library'][] = 'olivesnews/preserve-advanced-search';
}