Skip to content
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

The selection is not maintained, only if I add code inside onPlaceSelected #223

Open
nappalm opened this issue Sep 21, 2023 · 1 comment

Comments

@nappalm
Copy link

nappalm commented Sep 21, 2023

Because my current code does not work, however if I use only a console.log within onPlaceSelected the selection in the input is maintained correctly.

<Controller
              name="location"
              render={({ field, fieldState: { error } }) => {
                return (
                  <div>
                    <span style={{ color: 'black' }}>Location</span>
                    <Input
                      fullWidth
                      inputComponent={({ inputRef, onFocus, onBlur, ...props }) => (
                        <Autocomplete
                          apiKey="..."
                          {...props}
                          onPlaceSelected={(selected) => {
                            const lat = selected.geometry.location.lat();
                            const lng = selected.geometry.location.lng();

                            field.onChange({
                              lat,
                              lng,
                              formatted_address: selected.formatted_address,
                            });
                          }}
                        />
                      )}
                    />
                  </div>
                );
              }}
            />

Gif error:
ezgif-5-1ca7c007e4

@stefan-evernest
Copy link

First idea: did you checked if your Input or Controller component is rerendered for some reason, so it resets the value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants