-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible to have a callback if no autocomplete item is selected? #106
Comments
Would this work for your use case? // In `constructor`
this.state = {
address: '',
isAddressValid: false,
}
this.handleChange = (address) => this.setState({ address })
this.handleSelect = ({ placeId}) => this.setState({ isAddressValid: !!placeId })
this.handleBlur = () => {
if (!this.state.isAddressValid) {
this.setState({ address: '' })
}
}
// And in `render`
const inputProps = {
onChange: this.handleChange,
value: this.state.address,
onBlur: this.handleBlur,
}
<PlacesAutocomplete
inputProps={inputProps}
onSelect={this.handleSelect}
/> |
Oh this seems to work. Thanks a lot. |
This doesn't seem to work anymore. The blur event is never fired |
The blur event doesn't fire for me either. |
Any update on this? Would be great to be able to handle blur for the input |
If you pass the onBlur into the getInputProps it works:
|
Thanks @javidjamae for posting this 👍 |
Thanks! Just had to remove |
I am facing an issue whereby I would like to clear the value if no autocomplete item was selected.
The exact scenario is whereby I had typed in an address and then moved to the next field by pressing "Tab" without selecting any autocomplete item.
In order to invalidate the input field, I would want to clear the filled in address.
The text was updated successfully, but these errors were encountered: