Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 46242a1

Browse files
authored
Merge pull request #901 from matrix-org/luke/improve-country-dd-5
Fix a few remaining snags with country dd
2 parents 90ee0c7 + 32818af commit 46242a1

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/components/views/elements/Dropdown.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ export default class Dropdown extends React.Component {
152152
}
153153

154154
_onInputClick(ev) {
155-
this.setState({
156-
expanded: !this.state.expanded,
157-
});
158-
ev.preventDefault();
155+
if (!this.state.expanded) {
156+
this.setState({
157+
expanded: true,
158+
});
159+
ev.preventDefault();
160+
}
159161
}
160162

161163
_onMenuOptionClick(dropdownKey) {
@@ -252,7 +254,7 @@ export default class Dropdown extends React.Component {
252254
);
253255
});
254256
if (options.length === 0) {
255-
return [<div className="mx_Dropdown_option">
257+
return [<div key="0" className="mx_Dropdown_option">
256258
No results
257259
</div>];
258260
}

src/components/views/login/CountryDropdown.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ for (const c of COUNTRIES) {
2626
}
2727

2828
function countryMatchesSearchQuery(query, country) {
29+
// Remove '+' if present (when searching for a prefix)
30+
if (query[0] === '+') {
31+
query = query.slice(1);
32+
}
33+
2934
if (country.name.toUpperCase().indexOf(query.toUpperCase()) == 0) return true;
3035
if (country.iso2 == query.toUpperCase()) return true;
31-
if (country.prefix == query) return true;
36+
if (country.prefix.indexOf(query) !== -1) return true;
3237
return false;
3338
}
3439

@@ -107,7 +112,7 @@ export default class CountryDropdown extends React.Component {
107112
const options = displayedCountries.map((country) => {
108113
return <div key={country.iso2}>
109114
{this._flagImgForIso2(country.iso2)}
110-
{country.name}
115+
{country.name} <span>(+{country.prefix})</span>
111116
</div>;
112117
});
113118

0 commit comments

Comments
 (0)