Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multiple slider update on facetsearch #550

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading