From c065fb13bc2ffb825d28feaad958786c7cab35de Mon Sep 17 00:00:00 2001 From: Samuel Vaillant Date: Fri, 16 Feb 2018 14:15:14 +0100 Subject: [PATCH] fix(connectRange): update default refinement propTypes (#978) * fix(connectRange): allow default refinement to be an empty object * feat(RangeInputStories): add story with only one value for the defaultRefinement --- .../src/connectors/connectRange.js | 6 +++--- stories/RangeInput.stories.js | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/react-instantsearch/src/connectors/connectRange.js b/packages/react-instantsearch/src/connectors/connectRange.js index 95f235dea4..69a2e55054 100644 --- a/packages/react-instantsearch/src/connectors/connectRange.js +++ b/packages/react-instantsearch/src/connectors/connectRange.js @@ -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. @@ -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, diff --git a/stories/RangeInput.stories.js b/stories/RangeInput.stories.js index 758ed8c2a9..21f6f69974 100644 --- a/stories/RangeInput.stories.js +++ b/stories/RangeInput.stories.js @@ -70,6 +70,18 @@ stories ) .addWithJSX( 'with default value', + () => ( + + + + ), + { + displayName, + filterProps, + } + ) + .addWithJSX( + 'with default values', () => (