Skip to content

Commit d29dff6

Browse files
author
vvo
committed
fix(refinementList): singleRefine is not dependant from operator
1 parent 2b049c5 commit d29dff6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

widgets/refinement-list.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ function refinementList({
6767
throw new Error(usage);
6868
}
6969

70-
operator = operator.toLowerCase();
71-
if (operator !== 'and' && operator !== 'or') {
72-
throw new Error(usage);
70+
if (operator) {
71+
operator = operator.toLowerCase();
72+
if (operator !== 'and' && operator !== 'or') {
73+
throw new Error(usage);
74+
}
7375
}
7476

7577
return {
@@ -103,7 +105,12 @@ function refinementList({
103105

104106
function toggleRefinement(helper, singleRefine, facetName, facetValue) {
105107
if (singleRefine) {
106-
helper.clearRefinement(facetName);
108+
var previousRefinement = helper.getRefinements(facetName);
109+
helper.clearRefinements(facetName);
110+
if (previousRefinement && previousRefinement[0] && previousRefinement[0].value === facetValue) {
111+
helper.search();
112+
return;
113+
}
107114
}
108115

109116
helper

0 commit comments

Comments
 (0)