@@ -168,7 +168,7 @@ export default class Dropdown extends PureComponent {
168
168
169
169
this . keyExtractor = this . keyExtractor . bind ( this ) ;
170
170
171
- this . blur = this . onClose ;
171
+ this . blur = ( ) => this . onClose ( ) ;
172
172
this . focus = this . onPress ;
173
173
174
174
let { value } = this . props ;
@@ -309,7 +309,7 @@ export default class Dropdown extends PureComponent {
309
309
} ) ;
310
310
}
311
311
312
- onClose ( ) {
312
+ onClose ( value = this . state . value ) {
313
313
let { onBlur, animationDuration } = this . props ;
314
314
let { opacity } = this . state ;
315
315
@@ -327,7 +327,7 @@ export default class Dropdown extends PureComponent {
327
327
}
328
328
329
329
if ( this . mounted ) {
330
- this . setState ( { modal : false } ) ;
330
+ this . setState ( { value , modal : false } ) ;
331
331
}
332
332
} ) ;
333
333
}
@@ -336,13 +336,11 @@ export default class Dropdown extends PureComponent {
336
336
let { data, valueExtractor, onChangeText, animationDuration } = this . props ;
337
337
let value = valueExtractor ( data [ index ] , index ) ;
338
338
339
- this . setState ( { value } ) ;
340
-
341
339
if ( 'function' === typeof onChangeText ) {
342
340
onChangeText ( value , index , data ) ;
343
341
}
344
342
345
- setTimeout ( this . onClose , animationDuration ) ;
343
+ setTimeout ( ( ) => this . onClose ( value ) , animationDuration ) ;
346
344
}
347
345
348
346
onLayout ( event ) {
@@ -709,10 +707,10 @@ export default class Dropdown extends PureComponent {
709
707
< Modal
710
708
visible = { modal }
711
709
transparent = { true }
712
- onRequestClose = { this . onClose }
710
+ onRequestClose = { this . blur }
713
711
supportedOrientations = { supportedOrientations }
714
712
>
715
- < TouchableWithoutFeedback onPress = { this . onClose } >
713
+ < TouchableWithoutFeedback onPress = { this . blur } >
716
714
< View style = { overlayStyle } >
717
715
< Animated . View
718
716
style = { [ styles . picker , pickerStyle , pickerStyleOverrides ] }
0 commit comments