Skip to content

Commit

Permalink
Merge pull request #550 from tblivet/fix/facetsearch
Browse files Browse the repository at this point in the history
fix: multiple slider update on facetsearch
  • Loading branch information
nicosomb authored Jan 4, 2024
2 parents 3d20f3e + d53be35 commit 6711c8b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/js/constants/selectors-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
export const facetedsearch = {
range: '.js-faceted-slider',
rangeContainer: '.js-faceted-slider-container',
rangeValues: '.js-faceted-values',
filterSlider: '.js-faceted-filter-slider',
offCanvasFaceted: '#offcanvas-faceted',
};
Expand Down
9 changes: 6 additions & 3 deletions src/js/modules/facetedsearch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const initSliders = () => {
// Get all slider configurations found in the DOM
document.querySelectorAll(Theme.selectors.facetedsearch.filterSlider).forEach((filter: HTMLElement) => {
const container = <target>filter.querySelector(Theme.selectors.facetedsearch.rangeContainer);
const facetedValues = document.querySelector('.js-faceted-values') as HTMLElement;

// Init basic slider data
let unitPosition = 'suffix';
Expand Down Expand Up @@ -101,7 +100,9 @@ export const initSliders = () => {
unitPosition === 'suffix' ? `${value}${unitSymbol}` : `${unitSymbol}${value}`),
);

facetedValues.innerHTML = formattedValues.join(' - ');
const parentFacet = initiatedSlider.target.closest(Theme.selectors.facetedsearch.filterSlider) as HTMLElement;
const showValues = parentFacet.querySelector(Theme.selectors.facetedsearch.rangeValues) as HTMLElement;
showValues.innerHTML = formattedValues.join(' - ');
});
} else {
container.noUiSlider.updateOptions({
Expand All @@ -125,7 +126,9 @@ export const initSliders = () => {
unitPosition === 'suffix' ? `${value}${unitSymbol}` : `${unitSymbol}${value}`),
);

facetedValues.innerHTML = formattedValues.join(' - ');
const parentFacet = initiatedSlider.target.closest(Theme.selectors.facetedsearch.filterSlider) as HTMLElement;
const showValues = parentFacet.querySelector(Theme.selectors.facetedsearch.rangeValues) as HTMLElement;
showValues.innerHTML = formattedValues.join(' - ');
});
}
});
Expand Down

0 comments on commit 6711c8b

Please sign in to comment.