Skip to content

Commit cc02b71

Browse files
authored
fix(sffv): no error when not providing noResults and no results (#2310)
When there was no results and the template is not provided, is.js would trigger an error. Fix #2087
1 parent 3b30375 commit cc02b71

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

dev/app/init-builtin-widgets.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,25 @@ export default () => {
293293
);
294294
})
295295
)
296+
.add(
297+
'with search inside items (using the default noResults template)',
298+
wrapWithHits(container => {
299+
window.search.addWidget(
300+
instantsearch.widgets.refinementList({
301+
container,
302+
attributeName: 'brand',
303+
operator: 'or',
304+
limit: 10,
305+
templates: {
306+
header: 'Searchable brands',
307+
},
308+
searchForFacetValues: {
309+
placeholder: 'Find other brands...',
310+
},
311+
})
312+
);
313+
})
314+
)
296315
.add(
297316
'with operator `and`',
298317
wrapWithHits(container => {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
noResults: 'No results',
3+
};

src/widgets/refinement-list/refinement-list.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import filter from 'lodash/filter';
66
import RefinementList from '../../components/RefinementList/RefinementList.js';
77
import connectRefinementList from '../../connectors/refinement-list/connectRefinementList.js';
88
import defaultTemplates from './defaultTemplates.js';
9+
import sffvDefaultTemplates from './defaultTemplates.searchForFacetValue.js';
910
import getShowMoreConfig from '../../lib/show-more/getShowMoreConfig.js';
1011

1112
import {
@@ -253,7 +254,7 @@ export default function refinementList(
253254
? prefixKeys('show-more-', showMoreConfig.templates)
254255
: {};
255256
const searchForValuesTemplates = searchForFacetValues
256-
? searchForFacetValues.templates
257+
? searchForFacetValues.templates || sffvDefaultTemplates
257258
: {};
258259
const allTemplates = {
259260
...templates,

0 commit comments

Comments
 (0)