From da42a151219471ce7e78737416636584dd0eb198 Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Tue, 31 Oct 2017 11:38:49 +0100 Subject: [PATCH 1/4] fix(searchbox): add maxlength 512 The API can only handle queries up to 512 characters and would throw an error in this case (copy pasted addresses for example). This prevents users from typing more than possible, and would simply discard later characters fixes #510 (haha would be funny is that was issue 512) supported in all browsers, but would fall back nicely anyway: http://caniuse.com/#feat=maxlength cc @67ideas --- packages/react-instantsearch/src/components/SearchBox.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-instantsearch/src/components/SearchBox.js b/packages/react-instantsearch/src/components/SearchBox.js index fb0af8944a..68f3dd8c9f 100644 --- a/packages/react-instantsearch/src/components/SearchBox.js +++ b/packages/react-instantsearch/src/components/SearchBox.js @@ -227,6 +227,7 @@ class SearchBox extends Component { autoCapitalize="off" spellCheck="false" required + maxlength="512" value={query} onChange={this.onChange} {...searchInputEvents} From d51be4c8c3459e446dc5bdd4cc4f0fa4a9e46ff1 Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Wed, 1 Nov 2017 08:54:04 +0100 Subject: [PATCH 2/4] use maxLength instead of maxlength :react: --- packages/react-instantsearch/src/components/SearchBox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-instantsearch/src/components/SearchBox.js b/packages/react-instantsearch/src/components/SearchBox.js index 68f3dd8c9f..15fbbd102e 100644 --- a/packages/react-instantsearch/src/components/SearchBox.js +++ b/packages/react-instantsearch/src/components/SearchBox.js @@ -227,7 +227,7 @@ class SearchBox extends Component { autoCapitalize="off" spellCheck="false" required - maxlength="512" + maxLength="512" value={query} onChange={this.onChange} {...searchInputEvents} From 67e67f1cfaf040d112b8b52301524b48f6ddc1bc Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Wed, 1 Nov 2017 10:23:51 +0100 Subject: [PATCH 3/4] update snapshots --- .../src/components/__snapshots__/Menu.test.js.snap | 3 +++ .../components/__snapshots__/RefinementList.test.js.snap | 3 +++ .../src/components/__snapshots__/SearchBox.test.js.snap | 7 +++++++ scripts/boot.sh | 4 ++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/react-instantsearch/src/components/__snapshots__/Menu.test.js.snap b/packages/react-instantsearch/src/components/__snapshots__/Menu.test.js.snap index 3702d4a334..5a8eedfda7 100644 --- a/packages/react-instantsearch/src/components/__snapshots__/Menu.test.js.snap +++ b/packages/react-instantsearch/src/components/__snapshots__/Menu.test.js.snap @@ -54,6 +54,7 @@ exports[`Menu Menu with search inside items but no search results 1`] = ` autoCorrect="off" autoFocus={false} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="Search here…" required={true} @@ -219,6 +220,7 @@ exports[`Menu Menu with search inside items with search results 1`] = ` autoCorrect="off" autoFocus={false} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="Search here…" required={true} @@ -340,6 +342,7 @@ exports[`Menu applies translations 1`] = ` autoCorrect="off" autoFocus={false} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="placeholder" required={true} diff --git a/packages/react-instantsearch/src/components/__snapshots__/RefinementList.test.js.snap b/packages/react-instantsearch/src/components/__snapshots__/RefinementList.test.js.snap index c61164e952..46329553aa 100644 --- a/packages/react-instantsearch/src/components/__snapshots__/RefinementList.test.js.snap +++ b/packages/react-instantsearch/src/components/__snapshots__/RefinementList.test.js.snap @@ -55,6 +55,7 @@ exports[`RefinementList applies translations 1`] = ` autoCorrect="off" autoFocus={false} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="placeholder" required={true} @@ -309,6 +310,7 @@ exports[`RefinementList refinement list with search inside items but no search r autoCorrect="off" autoFocus={false} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="Search here…" required={true} @@ -491,6 +493,7 @@ exports[`RefinementList refinement list with search inside items with search res autoCorrect="off" autoFocus={false} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="Search here…" required={true} diff --git a/packages/react-instantsearch/src/components/__snapshots__/SearchBox.test.js.snap b/packages/react-instantsearch/src/components/__snapshots__/SearchBox.test.js.snap index e133280aa8..8360cddd29 100644 --- a/packages/react-instantsearch/src/components/__snapshots__/SearchBox.test.js.snap +++ b/packages/react-instantsearch/src/components/__snapshots__/SearchBox.test.js.snap @@ -48,6 +48,7 @@ exports[`SearchBox applies its default props 1`] = ` autoCorrect="off" autoFocus={false} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="Search here…" required={true} @@ -138,6 +139,7 @@ exports[`SearchBox lets you customize its theme 1`] = ` autoCorrect="off" autoFocus={false} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="Search here…" required={true} @@ -228,6 +230,7 @@ exports[`SearchBox lets you customize its translations 1`] = ` autoCorrect="off" autoFocus={false} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="PLACEHOLDER" required={true} @@ -318,6 +321,7 @@ exports[`SearchBox lets you give custom components for reset and submit 1`] = ` autoCorrect="off" autoFocus={false} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="Search here…" required={true} @@ -400,6 +404,7 @@ exports[`SearchBox transfers the autoFocus prop to the underlying input element autoCorrect="off" autoFocus={true} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="Search here…" required={true} @@ -490,6 +495,7 @@ exports[`SearchBox treats its query prop as its input value 1`] = ` autoCorrect="off" autoFocus={false} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="Search here…" required={true} @@ -580,6 +586,7 @@ exports[`SearchBox treats its query prop as its input value 2`] = ` autoCorrect="off" autoFocus={false} className="ais-SearchBox__input" + maxLength="512" onChange={[Function]} placeholder="Search here…" required={true} diff --git a/scripts/boot.sh b/scripts/boot.sh index 3310891c42..be47d56989 100755 --- a/scripts/boot.sh +++ b/scripts/boot.sh @@ -2,10 +2,10 @@ # Use this script to install dependencies of every packages rm -rf node_modules packages/react-instantsearch/node_modules packages/react-instantsearch-theme-algolia/node_modules && -NODE_ENV=development yarn && +NODE_ENV=development yarn --ignore-engines && (cd node_modules/react && yarn link) && (cd node_modules/react-dom && yarn link) && -(cd packages/react-instantsearch && yarn && yarn link && yarn link react && yarn link react-dom) && +(cd packages/react-instantsearch && yarn --ignore-engines && yarn link && yarn link react && yarn link react-dom) && (cd packages/react-instantsearch-theme-algolia && yarn && yarn link && yarn link react && yarn link react-dom) && yarn link react-instantsearch && yarn link react-instantsearch-theme-algolia From 174939b58e6b3c6d45f1c2020585e87810261f5c Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Wed, 1 Nov 2017 10:24:41 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=98=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/boot.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/boot.sh b/scripts/boot.sh index be47d56989..3310891c42 100755 --- a/scripts/boot.sh +++ b/scripts/boot.sh @@ -2,10 +2,10 @@ # Use this script to install dependencies of every packages rm -rf node_modules packages/react-instantsearch/node_modules packages/react-instantsearch-theme-algolia/node_modules && -NODE_ENV=development yarn --ignore-engines && +NODE_ENV=development yarn && (cd node_modules/react && yarn link) && (cd node_modules/react-dom && yarn link) && -(cd packages/react-instantsearch && yarn --ignore-engines && yarn link && yarn link react && yarn link react-dom) && +(cd packages/react-instantsearch && yarn && yarn link && yarn link react && yarn link react-dom) && (cd packages/react-instantsearch-theme-algolia && yarn && yarn link && yarn link react && yarn link react-dom) && yarn link react-instantsearch && yarn link react-instantsearch-theme-algolia