Skip to content

Commit 42191a0

Browse files
author
Eunjae Lee
authoredMar 30, 2021
feat(ratingMenu): implement canRefine (#4691)
* feat(ratingMenu): implement canRefine * update canRefine
1 parent 48dc7f8 commit 42191a0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed
 

‎src/connectors/rating-menu/__tests__/connectRatingMenu-test.js

+4
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/rating-menu
467467
grade: {
468468
items: [],
469469
createURL: expect.any(Function),
470+
canRefine: false,
470471
refine: expect.any(Function),
471472
sendEvent: expect.any(Function),
472473
hasNoResults: true,
@@ -546,6 +547,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/rating-menu
546547
},
547548
],
548549
createURL: expect.any(Function),
550+
canRefine: true,
549551
refine: expect.any(Function),
550552
sendEvent: renderState1.ratingMenu.grade.sendEvent,
551553
hasNoResults: true,
@@ -581,6 +583,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/rating-menu
581583
expect(renderState1).toEqual({
582584
items: [],
583585
createURL: expect.any(Function),
586+
canRefine: false,
584587
refine: expect.any(Function),
585588
sendEvent: expect.any(Function),
586589
hasNoResults: true,
@@ -658,6 +661,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/rating-menu
658661
},
659662
],
660663
createURL: expect.any(Function),
664+
canRefine: true,
661665
refine: expect.any(Function),
662666
sendEvent: renderState1.sendEvent,
663667
hasNoResults: true,

‎src/connectors/rating-menu/connectRatingMenu.js

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const createSendEvent = ({
6666
* @property {StarRatingItems[]} items Possible star ratings the user can apply.
6767
* @property {function(string): string} createURL Creates an URL for the next
6868
* state (takes the item value as parameter). Takes the value of an item as parameter.
69+
* @property {boolean} canRefine Indicates if search state can be refined.
6970
* @property {function(string)} refine Selects a rating to filter the results
7071
* (takes the filter value as parameter). Takes the value of an item as parameter.
7172
* @property {boolean} hasNoResults `true` if the last search contains no result.
@@ -328,6 +329,7 @@ ${
328329
return {
329330
items: facetValues,
330331
hasNoResults: results ? results.nbHits === 0 : true,
332+
canRefine: facetValues.length > 0,
331333
refine: connectorState.toggleRefinementFactory(helper),
332334
sendEvent,
333335
createURL: connectorState.createURLFactory({ state, createURL }),

0 commit comments

Comments
 (0)
Please sign in to comment.