diff --git a/demo/src/pages/Search.js b/demo/src/pages/Search.js index 1526ed44..eb41804e 100644 --- a/demo/src/pages/Search.js +++ b/demo/src/pages/Search.js @@ -74,6 +74,8 @@ 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 && @@ -81,10 +83,12 @@ const Search = () => { ) { 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 { @@ -92,6 +96,7 @@ const Search = () => { } 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 { diff --git a/src/modules/rangeFacets/utils/utils.js b/src/modules/rangeFacets/utils/utils.js index 14ae485f..6293c606 100644 --- a/src/modules/rangeFacets/utils/utils.js +++ b/src/modules/rangeFacets/utils/utils.js @@ -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; diff --git a/src/modules/textFacets/utils/utils.js b/src/modules/textFacets/utils/utils.js index dceae273..4c923c43 100644 --- a/src/modules/textFacets/utils/utils.js +++ b/src/modules/textFacets/utils/utils.js @@ -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,