Skip to content

Commit

Permalink
Merge pull request #119 from AddSearch/sc-10250/fix-range-facets-slid…
Browse files Browse the repository at this point in the history
…er-not-rendered-with-range-facets-checkbox

fix: [sc-10250] Bug in Search-UI Lib's rangeFacet slider
  • Loading branch information
haoAddsearch authored Jul 18, 2024
2 parents 37b8c04 + 7eb636b commit 7f5a3fc
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/addsearch-search-ui.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/addsearch-search-ui.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "addsearch-search-ui",
"version": "0.8.8",
"version": "0.8.9",
"description": "JavaScript library to develop Search UIs for the web",
"main": "./dist/addsearch-search-ui.min.js",
"jsdelivr": "./dist/addsearch-search-ui.min.js",
Expand Down
15 changes: 13 additions & 2 deletions src/components/facets/facets.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export default class Facets {
client.fetchCustomApi(this.conf.field, filterObjectCustom, res => {
this.render(res, true);
})
} else {
const activeFacets = this.getActiveFacets(this.conf.field);
this.updateCheckboxStates(activeFacets);
}
}
});
Expand Down Expand Up @@ -67,7 +70,6 @@ export default class Facets {
facets = results.facets[facetField];
}


// Read active facets from redux state
const activeFacets = this.getActiveFacets(facetField);

Expand Down Expand Up @@ -140,4 +142,13 @@ export default class Facets {
}
return activeFacets;
}
}

updateCheckboxStates(activeFacets) {
const container = document.getElementById(this.conf.containerId);
const options = container.getElementsByTagName('input');
for (let i=0; i < options.length; i++) {
let checkbox = options[i];
checkbox.checked = activeFacets.indexOf(checkbox.value) !== -1;
}
}
}
7 changes: 4 additions & 3 deletions src/components/rangefacets/rangefacets.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ export default class RangeFacets {

observeStoreByKey(this.reduxStore, 'fieldstats', (state) => {
var fieldStats = state.fieldStats[this.conf.field];
if (!fieldStats) {
this.renderRangeSlider();

if (state.callBy !== this.conf.field || fieldStats === undefined) {
return;
}

if (state.callBy !== this.conf.field) {
if (fieldStats === null) {
this.renderRangeSlider();
return;
}

Expand Down

0 comments on commit 7f5a3fc

Please sign in to comment.