diff --git a/packages/react-instantsearch/src/connectors/connectSearchBox.js b/packages/react-instantsearch/src/connectors/connectSearchBox.js
index 95ba1a20e8..b27cc516d8 100644
--- a/packages/react-instantsearch/src/connectors/connectSearchBox.js
+++ b/packages/react-instantsearch/src/connectors/connectSearchBox.js
@@ -10,6 +10,9 @@ function getCurrentRefinement(props, searchState) {
if (typeof searchState[id] !== 'undefined') {
return searchState[id];
}
+ if (typeof props.defaultRefinement === 'string') {
+ return props.defaultRefinement;
+ }
return '';
}
diff --git a/packages/react-instantsearch/src/connectors/connectSearchBox.test.js b/packages/react-instantsearch/src/connectors/connectSearchBox.test.js
index 4913bd7da2..5d8a2f851a 100644
--- a/packages/react-instantsearch/src/connectors/connectSearchBox.test.js
+++ b/packages/react-instantsearch/src/connectors/connectSearchBox.test.js
@@ -32,6 +32,14 @@ describe('connectSearchBox', () => {
});
});
+ it('supports defaultRefinement', () => {
+ expect(
+ getProvidedProps({defaultRefinement: 'yaw'}, {})
+ ).toEqual({
+ currentRefinement: 'yaw',
+ });
+ });
+
it('refines the query parameter', () => {
params = getSP(new SearchParameters(), {}, {query: 'bar'});
expect(params.query).toBe('bar');
diff --git a/stories/SearchBox.stories.js b/stories/SearchBox.stories.js
index 98d3fec56c..40fc4b784e 100644
--- a/stories/SearchBox.stories.js
+++ b/stories/SearchBox.stories.js
@@ -12,7 +12,12 @@ stories.add('default', () =>
-).add('playground', () =>
+).add('with a default query', () =>
+
+
+
+)
+.add('playground', () =>