Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(connectRange): update default refinement propTypes (#978)
Browse files Browse the repository at this point in the history
* fix(connectRange): allow default refinement to be an empty object

* feat(RangeInputStories): add story with only one value for the defaultRefinement
  • Loading branch information
samouss authored Feb 16, 2018
1 parent ea3063a commit c065fb1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react-instantsearch/src/connectors/connectRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import createConnector from '../core/createConnector';
* @kind connector
* @requirements The attribute passed to the `attributeName` prop must be holding numerical values.
* @propType {string} attributeName - Name of the attribute for faceting
* @propType {{min: number, max: number}} [defaultRefinement] - Default searchState of the widget containing the start and the end of the range.
* @propType {{min?: number, max?: number}} [defaultRefinement] - Default searchState of the widget containing the start and the end of the range.
* @propType {number} [min] - Minimum value. When this isn't set, the minimum value will be automatically computed by Algolia using the data in the index.
* @propType {number} [max] - Maximum value. When this isn't set, the maximum value will be automatically computed by Algolia using the data in the index.
* @propType {number} [precision=2] - Number of digits after decimal point to use.
Expand Down Expand Up @@ -185,8 +185,8 @@ export default createConnector({
id: PropTypes.string,
attributeName: PropTypes.string.isRequired,
defaultRefinement: PropTypes.shape({
min: PropTypes.number.isRequired,
max: PropTypes.number.isRequired,
min: PropTypes.number,
max: PropTypes.number,
}),
min: PropTypes.number,
max: PropTypes.number,
Expand Down
12 changes: 12 additions & 0 deletions stories/RangeInput.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ stories
)
.addWithJSX(
'with default value',
() => (
<WrapWithHits linkedStoryGroup="RangeInput">
<RangeInput attributeName="price" defaultRefinement={{ min: 50 }} />
</WrapWithHits>
),
{
displayName,
filterProps,
}
)
.addWithJSX(
'with default values',
() => (
<WrapWithHits linkedStoryGroup="RangeInput">
<RangeInput
Expand Down

0 comments on commit c065fb1

Please sign in to comment.