Hello there, and thanks for the awesome lib :)
I'm trying to focus the textinput inside autocomplete, but unfortunately method _triggerFocus_ isn't working :( It literally does nothing.
Any advice on how to procede?
Hello, find a trick ?
@MayoudP Unfortunately nope :(
Hello there,
First, get a reference to GooglePlacesAutocomplete Component and the call triggerFocus like bellow.
const [autoComplete, setAutoComplete] = useState(null);
// when ever the coponent is mounted the text input will be on focus
useEffect(() => {
if (autoComplete !== null) {
autoComplete.triggerFocus();
}
}, [autoComplete]);
<GooglePlacesAutocomplete
ref={ref => setAutoComplete(ref) }
// other props here
/>
Hi @FRizzonelli can you please provide a reproducible example of this by showing some code or better yet, linking to a snack?
Dude this isn't fixed. I need a moment to create the snack. By the way, if u try to pass the ref of the textinput to googleplaces, and try to call "focus()" on it, it doesn't work.
Plus, no one answered for like months and you close it after 2 working days.
Feel free to open a new issue.
This is an open source project. There are no guarantees, SLAs, or support timelines. I just joined this repo as a maintainer, and I am trying to bring the library up to date and go through the over 100 open issues and 30 PR to get some high priority work done. This issue was opened last summer and there is one potential answer here with no response. I thought it was reasonable to close the issue at that point.
Closed != fixed
get ref onFocus inside textInputProps
constructor(props) {
super(props);
this.textInput = React.createRef();
}
<GooglePlacesAutocomplete
textInputProps={{
ref: this.textInput,
}}
/>
and call => this.textInput.current.focus()
Most helpful comment
get ref onFocus inside textInputProps