-
Notifications
You must be signed in to change notification settings - Fork 386
feat(connectToggleRefinement): implement canRefine & count #1588
Conversation
db9ecc1
to
0f1c9d9
Compare
Deploy preview for react-instantsearch ready! Built with commit b279620 https://deploy-preview-1588--react-instantsearch.netlify.com |
23e226f
to
5744cfd
Compare
expect(params.getDisjunctiveRefinements('facet')).toEqual(['val']); | ||
}); | ||
|
||
it('does not refines the corresponding facet with `false`', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refines
→ refine
return { currentRefinement }; | ||
|
||
const facetValues = results && results.getFacetValues(attribute); | ||
const facetValue = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two variable names are confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions? I didn't find something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I deal with both singular and plural variable names, I tend to go for allFacetValues
and facetValue
. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest I don't see a huge benefit, I'm used to the plural singular form like the original one. But I get your point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I came across these two lines I thought you were referring to the same variable. The benefit is just to avoid this confusion. This is subjective though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I've renamed it.
packages/react-instantsearch-core/src/connectors/connectToggleRefinement.js
Outdated
Show resolved
Hide resolved
5744cfd
to
4494ea1
Compare
4494ea1
to
b279620
Compare
<a name="5.3.0"></a> # [5.3.0](v5.2.3...v5.3.0) (2018-09-24) ### Bug Fixes * **SSR:** bind getSearchParmaters to the component instance ([f34cb3d](f34cb3d)) * **GoogleMapsLoader:** pick google maps version ([#1540](#1540)) ([b14efcf](b14efcf)) ### Features * **connectToggleRefinement:** implement canRefine & count ([#1588](#1588)) ([40672dd](40672dd))
@samouss it seems that this PR is causing a crash when we use ToggleRefinement and change the index used by InstantSearch widget
I spent the whole day trying to figure out what happen and finally came back to 5.2.3 |
Hi @VincentCtr, sorry about that. |
Hi @samouss, thank you for this very quick fix ! |
The PR has been merged and released (v5.3.1), let me know if you still have any issues. |
Summary
This PR adds
canRefine
&count
on the provided props of theconnectToggleRefinement
connector. I didn't implement the count on the widget because it will be a breaking change only in the connector.The count object has the following shape (see below). When the
currentRefinement
isfalse
(unchecked) the user can pick theunchecked
attribute. It displays the number of results that match the value provided to the Toggle widget. Once it's checked the count displays the total number of results (compute from the facet values).Changes:
SearchParameters
(conjunctiveFacet -> disjunctiveFacet)providedProps
(addscanRefine
&count
)noRefinement
class on the Toggle root element