This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -152,10 +152,12 @@ export default class Dropdown extends React.Component {
152
152
}
153
153
154
154
_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
+ }
159
161
}
160
162
161
163
_onMenuOptionClick ( dropdownKey ) {
@@ -252,7 +254,7 @@ export default class Dropdown extends React.Component {
252
254
) ;
253
255
} ) ;
254
256
if ( options . length === 0 ) {
255
- return [ < div className = "mx_Dropdown_option" >
257
+ return [ < div key = "0" className = "mx_Dropdown_option" >
256
258
No results
257
259
</ div > ] ;
258
260
}
Original file line number Diff line number Diff line change @@ -26,9 +26,14 @@ for (const c of COUNTRIES) {
26
26
}
27
27
28
28
function countryMatchesSearchQuery ( query , country ) {
29
+ // Remove '+' if present (when searching for a prefix)
30
+ if ( query [ 0 ] === '+' ) {
31
+ query = query . slice ( 1 ) ;
32
+ }
33
+
29
34
if ( country . name . toUpperCase ( ) . indexOf ( query . toUpperCase ( ) ) == 0 ) return true ;
30
35
if ( country . iso2 == query . toUpperCase ( ) ) return true ;
31
- if ( country . prefix == query ) return true ;
36
+ if ( country . prefix . indexOf ( query ) ! == - 1 ) return true ;
32
37
return false ;
33
38
}
34
39
@@ -107,7 +112,7 @@ export default class CountryDropdown extends React.Component {
107
112
const options = displayedCountries . map ( ( country ) => {
108
113
return < div key = { country . iso2 } >
109
114
{ this . _flagImgForIso2 ( country . iso2 ) }
110
- { country . name }
115
+ { country . name } < span > (+ { country . prefix } ) </ span >
111
116
</ div > ;
112
117
} ) ;
113
118
You can’t perform that action at this time.
0 commit comments