From d6093f19b00c9816c2f628a6f735ff1d186cf69b Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Mon, 20 Feb 2017 11:04:41 -0500 Subject: [PATCH 1/4] Fix React key warnings The number of warnings was locking up my browser, making it hard to test things out. --- src/components/grid/grid.jsx | 6 +++--- src/components/thumbnail/thumbnail.jsx | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/grid/grid.jsx b/src/components/grid/grid.jsx index 93572840d..9100cacbc 100644 --- a/src/components/grid/grid.jsx +++ b/src/components/grid/grid.jsx @@ -27,12 +27,12 @@ var Grid = React.createClass({ return (
- {this.props.items.map(function (item) { + {this.props.items.map(function (item, key) { var href = '/' + this.props.itemType + '/' + item.id + '/'; if (this.props.itemType == 'projects') { return ( - + imgElement = {this.props.alt} ; - titleElement = {this.props.title}; + titleElement = + {this.props.title} + ; } else { imgElement = ; titleElement = this.props.title; From 0313346fedf91727e9a7389e7c1d52b9454342a7 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Mon, 20 Feb 2017 11:08:05 -0500 Subject: [PATCH 2/4] Encode term from search view's search bar Same fix as #1175, but for the form on the search page. --- src/views/search/search.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx index f3d0e5e1c..bf098fff9 100644 --- a/src/views/search/search.jsx +++ b/src/views/search/search.jsx @@ -76,7 +76,7 @@ var Search = injectIntl(React.createClass({ }.bind(this)); }, onSearchSubmit: function (formData) { - window.location.href = '/search/projects?q=' + formData.q; + window.location.href = '/search/projects?q=' + encodeURIComponent(formData.q); }, getTab: function (type) { var term = this.props.searchTerm.split(' ').join('+'); From 405763246d944e78eee4ea3fb2b5081c7de11504 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Mon, 20 Feb 2017 11:08:36 -0500 Subject: [PATCH 3/4] Wait for the search term before searching Fixes #1189 --- src/views/search/search.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx index bf098fff9..6ed6dd2ea 100644 --- a/src/views/search/search.jsx +++ b/src/views/search/search.jsx @@ -51,14 +51,16 @@ var Search = injectIntl(React.createClass({ while (term.indexOf('&') > -1) { term = term.substring(0, term.indexOf('&')); } - term = term.split('+').join(' '); - this.getSearchMore(); - this.props.dispatch(navigationActions.setSearchTerm(decodeURI(term))); + term = decodeURI(term.split('+').join(' ')); + this.props.dispatch(navigationActions.setSearchTerm(term)); + }, + componentDidUpdate: function (nextProps) { + if (this.props.searchTerm !== nextProps.searchTerm) this.getSearchMore(); }, getSearchMore: function () { var termText = ''; if (this.props.searchTerm !== '') { - termText = '&q=' + this.props.searchTerm; + termText = '&q=' + encodeURIComponent(this.props.searchTerm.split(' ').join('+')); } api({ uri: '/search/' + this.props.tab + From 601972645311de01dbee226142691ab2b88379fe Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Tue, 21 Feb 2017 09:42:34 -0500 Subject: [PATCH 4/4] Fix argument name Thanks @mewtaylor! --- src/views/search/search.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx index 6ed6dd2ea..87b4ce78d 100644 --- a/src/views/search/search.jsx +++ b/src/views/search/search.jsx @@ -54,8 +54,8 @@ var Search = injectIntl(React.createClass({ term = decodeURI(term.split('+').join(' ')); this.props.dispatch(navigationActions.setSearchTerm(term)); }, - componentDidUpdate: function (nextProps) { - if (this.props.searchTerm !== nextProps.searchTerm) this.getSearchMore(); + componentDidUpdate: function (prevProps) { + if (this.props.searchTerm !== prevProps.searchTerm) this.getSearchMore(); }, getSearchMore: function () { var termText = '';