Skip to content

Commit

Permalink
fix(selected facets): add an extra check to detect empty selected fac…
Browse files Browse the repository at this point in the history
…ets list
  • Loading branch information
sanjithkumar017 committed Jan 12, 2021
1 parent dc6a4bd commit 0fcdb72
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions demo/src/pages/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,29 @@ const Search = () => {
const { redirect = {} } = responseObj;
const { type = '', value } = redirect;
const urlParams = searchObj.getQueryParams();
// check if it is the home page and we don't have any query params on the url.
// return false to ensure sdk makes no further search calls
if (
routeLocation.pathname === '/' &&
Object.keys(urlParams).length === 0 &&
refreshId
) {
return false;
} else if (
// check for redirects
type === 'url' &&
typeof value === 'string' &&
value.length > 0
) {
// if hash already exists, to retain the current state, push on history
if (routeLocation.pathname === '/' && routeLocation.hash) {
routeHistory.push(value);
} else {
routeHistory.replace(value);
}
return true;
} else {
// if hash already exists, to retain the current state, push on history
if (routeLocation.hash && routeHistory.action !== 'POP') {
routeHistory.push(`${routeLocation.pathname}#${hash}`);
} else {
Expand Down
5 changes: 4 additions & 1 deletion src/modules/rangeFacets/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export const getFormattedRangeFacets = (rangeFacets, selectedRangeFacets) => {
const formattedFacets = rangeFacets.map((facetObj) => {
const { facetName } = facetObj;

if (selectedRangeFacets[facetName]) {
if (
selectedRangeFacets[facetName] &&
selectedRangeFacets[facetName].length
) {
const { start, end } = facetObj;
const sliderMin = start;
const sliderMax = end;
Expand Down
5 changes: 4 additions & 1 deletion src/modules/textFacets/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ export const getTextFacetItem = (facetObjectValues, dataId) => {
export const getFormattedTextFacets = (textFacets, selectedTextFacets) => {
const formattedFacets = textFacets.map((facetObj) => {
const { facetName } = facetObj;
if (selectedTextFacets[facetName]) {
if (
selectedTextFacets[facetName] &&
selectedTextFacets[facetName].length
) {
const currentFacetObj = {
facetType: facetTypes.TEXT_FACET,
...facetObj,
Expand Down

0 comments on commit 0fcdb72

Please sign in to comment.