@@ -111,7 +111,7 @@ export default class InputSelect extends Component {
111
111
let i = 0 ;
112
112
let node = e . target ;
113
113
const REG = new RegExp ( _id ) ;
114
- while ( node && i < 5 ) {
114
+ while ( node && i < 20 ) {
115
115
if ( REG . test ( node . className ) ) {
116
116
return true ;
117
117
}
@@ -131,6 +131,7 @@ export default class InputSelect extends Component {
131
131
placeholder,
132
132
labelKey,
133
133
options,
134
+ onKeyPress,
134
135
} = this . props ;
135
136
136
137
const {
@@ -139,9 +140,10 @@ export default class InputSelect extends Component {
139
140
filterVal,
140
141
} = this . state ;
141
142
143
+ const escapeRegExp = stringToGoIntoTheRegex => stringToGoIntoTheRegex . replace ( / [ - \/ \\ ^ $ * + ? . ( ) | [ \] { } ] / g, '\\$&' ) ; /* eslint-disable-line no-useless-escape */
142
144
let fiterList = options ;
143
145
if ( filterVal ) {
144
- const REG = new RegExp ( filterVal , 'i' ) ;
146
+ const REG = new RegExp ( escapeRegExp ( filterVal ) , 'i' ) ;
145
147
fiterList = filter ( options , o => REG . test ( o [ labelKey ] ) ) ;
146
148
}
147
149
const list = map ( fiterList , o => (
@@ -171,7 +173,7 @@ export default class InputSelect extends Component {
171
173
< div styleName = "modal" >
172
174
< div styleName = "modal-input-container" >
173
175
174
- < input type = "text" onChange = { this . onFilterChange } placeholder = "Search" />
176
+ < input type = "text" onChange = { this . onFilterChange } placeholder = "Search" onKeyPress = { onKeyPress } />
175
177
</ div >
176
178
< div styleName = "modal-list-container" onScroll = { this . onLoadMore } >
177
179
{ list }
@@ -195,6 +197,7 @@ InputSelect.defaultProps = {
195
197
isLoading : false ,
196
198
onChange : ( ) => { } ,
197
199
onLoadMore : ( ) => { } ,
200
+ onKeyPress : ( ) => { } ,
198
201
} ;
199
202
200
203
InputSelect . propTypes = {
@@ -205,6 +208,7 @@ InputSelect.propTypes = {
205
208
placeholder : PT . string ,
206
209
onChange : PT . func ,
207
210
onLoadMore : PT . func ,
211
+ onKeyPress : PT . func ,
208
212
hasMore : PT . bool ,
209
213
isLoading : PT . bool ,
210
214
disabled : PT . bool ,
0 commit comments