-
Notifications
You must be signed in to change notification settings - Fork 386
fix(connectRange): check if facet exist before access #797
Conversation
ccc3a2d
to
9952766
Compare
Deploy preview ready! Built with commit 04f2e07 |
169e330
to
83f98d8
Compare
b7acfcc
to
6505f85
Compare
6505f85
to
735b21b
Compare
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.
looks good, just a proposed name change
@@ -190,8 +190,13 @@ export default createConnector({ | |||
getProvidedProps(props, searchState, searchResults) { | |||
const { attributeName, precision, min: minBound, max: maxBound } = props; | |||
const results = getResults(searchResults, this.context); | |||
const stats = results ? results.getFacetStats(attributeName) || {} : {}; | |||
const count = results | |||
const isFacetExist = results && results.getFacetByName(attributeName); |
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.
facetExists
seems like a better name
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.
I prefer to prefix all the boolean value like one with is
or has
it make them explicit. Would you agree for isFacetExists
?
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.
makes sense, but grammatically it reads weird. What about hasFacet
as something which matches the pattern but also grammar?
@Haroenv should be good now! |
<a name="4.4.1"></a> ## [4.4.1](v4.4.0...v4.4.1) (2018-01-09) ### Bug Fixes * **SearchBox**: clear SearchBox without search as you type ([#802](#802)) ([c49b2b6](c49b2b6)) * **connectRange:** check if facet exist before access ([#797](#797)) ([6520760](6520760)) * **stories:** avoid to use linear-background it breaks Argos every time ([#804](#804)) ([0beded7](0beded7)) * **stories:** limit hits per page on Index ([#806](#806)) ([6eb14d3](6eb14d3)) ### Features * **Index:** allow custom root ([#792](#792)) ([d793b0a](d793b0a))
Summary
Fix #630
In the
connectRange
we need to access the stats & the values of the given facet in order to compute the range. But it may happen that the facet is not yet present on the results so we need to check that the facet is present on results before accessing it.