From f99fa3ac1adf6be672515aa684c13ed2b3d9f01c Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 18 May 2017 16:58:57 +0100 Subject: [PATCH 1/5] Fixed pressing space or clicking dd input closes dd --- src/components/views/elements/Dropdown.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/views/elements/Dropdown.js b/src/components/views/elements/Dropdown.js index b4d2545e04..1b1e27cb65 100644 --- a/src/components/views/elements/Dropdown.js +++ b/src/components/views/elements/Dropdown.js @@ -152,10 +152,12 @@ export default class Dropdown extends React.Component { } _onInputClick(ev) { - this.setState({ - expanded: !this.state.expanded, - }); - ev.preventDefault(); + if (!this.state.expanded) { + this.setState({ + expanded: !this.state.expanded, + }); + ev.preventDefault(); + } } _onMenuOptionClick(dropdownKey) { From a425909b76c771820529b85c98bb453c78bc81bc Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 18 May 2017 17:01:01 +0100 Subject: [PATCH 2/5] Get rid of react key warning when no results --- src/components/views/elements/Dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/elements/Dropdown.js b/src/components/views/elements/Dropdown.js index 1b1e27cb65..718050c010 100644 --- a/src/components/views/elements/Dropdown.js +++ b/src/components/views/elements/Dropdown.js @@ -254,7 +254,7 @@ export default class Dropdown extends React.Component { ); }); if (options.length === 0) { - return [
+ return [
No results
]; } From 384f50609d92ed9e525f261ea6bf4a64d97b401c Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 18 May 2017 17:01:40 +0100 Subject: [PATCH 3/5] Allow searching by partial prefix (/w or /wo '+') --- src/components/views/login/CountryDropdown.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/views/login/CountryDropdown.js b/src/components/views/login/CountryDropdown.js index 8f342203bf..8369912570 100644 --- a/src/components/views/login/CountryDropdown.js +++ b/src/components/views/login/CountryDropdown.js @@ -26,9 +26,14 @@ for (const c of COUNTRIES) { } function countryMatchesSearchQuery(query, country) { + // Remove '+' if present (when searching for a prefix) + if (query[0] === '+') { + query = query.slice(1); + } + if (country.name.toUpperCase().indexOf(query.toUpperCase()) == 0) return true; if (country.iso2 == query.toUpperCase()) return true; - if (country.prefix == query) return true; + if (country.prefix.indexOf(query) !== -1) return true; return false; } From ee64f4a8dd4aedf29d385eaac92b424ad6a03edc Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 18 May 2017 17:02:19 +0100 Subject: [PATCH 4/5] Add country prefix to country dd options --- src/components/views/login/CountryDropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/login/CountryDropdown.js b/src/components/views/login/CountryDropdown.js index 8369912570..7024db339c 100644 --- a/src/components/views/login/CountryDropdown.js +++ b/src/components/views/login/CountryDropdown.js @@ -112,7 +112,7 @@ export default class CountryDropdown extends React.Component { const options = displayedCountries.map((country) => { return
{this._flagImgForIso2(country.iso2)} - {country.name} + {country.name} (+{country.prefix})
; }); From 32818aff4f888579cfc9b7cb6bea5fb55522e3e7 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 18 May 2017 17:08:26 +0100 Subject: [PATCH 5/5] Simplify expression --- src/components/views/elements/Dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/elements/Dropdown.js b/src/components/views/elements/Dropdown.js index 718050c010..82f8d753a9 100644 --- a/src/components/views/elements/Dropdown.js +++ b/src/components/views/elements/Dropdown.js @@ -154,7 +154,7 @@ export default class Dropdown extends React.Component { _onInputClick(ev) { if (!this.state.expanded) { this.setState({ - expanded: !this.state.expanded, + expanded: true, }); ev.preventDefault(); }