Skip to content

Commit

Permalink
fix(sffv): no error when not providing noResults and no results (#2310)
Browse files Browse the repository at this point in the history
When there was no results and the template is not provided, is.js would
trigger an error.

Fix #2087
  • Loading branch information
bobylito authored Sep 5, 2017
1 parent 3b30375 commit cc02b71
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
19 changes: 19 additions & 0 deletions dev/app/init-builtin-widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,25 @@ export default () => {
);
})
)
.add(
'with search inside items (using the default noResults template)',
wrapWithHits(container => {
window.search.addWidget(
instantsearch.widgets.refinementList({
container,
attributeName: 'brand',
operator: 'or',
limit: 10,
templates: {
header: 'Searchable brands',
},
searchForFacetValues: {
placeholder: 'Find other brands...',
},
})
);
})
)
.add(
'with operator `and`',
wrapWithHits(container => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
noResults: 'No results',
};
3 changes: 2 additions & 1 deletion src/widgets/refinement-list/refinement-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import filter from 'lodash/filter';
import RefinementList from '../../components/RefinementList/RefinementList.js';
import connectRefinementList from '../../connectors/refinement-list/connectRefinementList.js';
import defaultTemplates from './defaultTemplates.js';
import sffvDefaultTemplates from './defaultTemplates.searchForFacetValue.js';
import getShowMoreConfig from '../../lib/show-more/getShowMoreConfig.js';

import {
Expand Down Expand Up @@ -253,7 +254,7 @@ export default function refinementList(
? prefixKeys('show-more-', showMoreConfig.templates)
: {};
const searchForValuesTemplates = searchForFacetValues
? searchForFacetValues.templates
? searchForFacetValues.templates || sffvDefaultTemplates
: {};
const allTemplates = {
...templates,
Expand Down

0 comments on commit cc02b71

Please sign in to comment.