Skip to content

Commit

Permalink
add workaround for RNW onBlur issue (#649)
Browse files Browse the repository at this point in the history
  • Loading branch information
bell-steven committed Nov 9, 2020
1 parent dbdb653 commit ce02189
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions GooglePlacesAutocomplete.js
Expand Up @@ -643,6 +643,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
};

const _onBlur = () => {
props.textInputProps.onBlur;
setListViewDisplayed(false);
inputRef?.current?.blur();
};
Expand Down Expand Up @@ -745,7 +746,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {

let {
onFocus,
onBlur,
onBlur,// destructuring here stops this being set after onBlur={_onBlur}
onChangeText, // destructuring here stops this being set after onChangeText={_handleChangeText}
clearButtonMode,
InputComp,
Expand Down Expand Up @@ -784,14 +785,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
}
: _onFocus
}
onBlur={
onBlur
? () => {
_onBlur();
onBlur();
}
: _onBlur
}
onBlur={_onBlur}
clearButtonMode={clearButtonMode || 'while-editing'}
onChangeText={_handleChangeText}
{...userProps}
Expand Down Expand Up @@ -889,7 +883,9 @@ GooglePlacesAutocomplete.defaultProps = {
styles: {},
suppressDefaultStyles: false,
textInputHide: false,
textInputProps: {},
textInputProps: {
onBlur: () => '',
},
timeout: 20000,
};

Expand Down

0 comments on commit ce02189

Please sign in to comment.