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

Input value does not reset on context value reset #16

Closed
mkbctrl opened this issue Dec 18, 2022 · 4 comments
Closed

Input value does not reset on context value reset #16

mkbctrl opened this issue Dec 18, 2022 · 4 comments

Comments

@mkbctrl
Copy link

mkbctrl commented Dec 18, 2022

I am not 100% sure it's an issue, but it looks like one to me. I am using your component with ReactHookForm via Controller:

<Controller
    control={control}
    name="created"
    render={({ field: { onChange, value } }) => {
      return (
        // Input text is not cleared on form reset, value is emptied properly
        <Datepicker
          value={value}
          onChange={onChange}
          useRange={false}
          primaryColor="indigo"
          placeholder={t('filters.date.placeholder.created')}
        />
      )
    }}
  />

and when I attempt to reset the form values, the value inside the state gets cleared, but the value of the input does not.
Is it on purpose and I am not getting smth or it's a legit bug?

Here the recording when I clear the state values:
https://user-images.githubusercontent.com/10107362/208317554-2db7671f-cfb3-4bd4-a01d-8c44d1b4e299.mov

@onesine
Copy link
Owner

onesine commented Dec 19, 2022

Hi @mkbctrl 👋

Thanks for your feedback.

I think like you that it must be a bug. But I will try it myself to see.

PR's are always welcome.

@NoahMLoomis
Copy link
Contributor

Hey @mkbctrl, that's an odd bug. I'm using react-hook-form as well with a controller and it works fine for me. Could be that the useRange prop or placeholder is messing something up?

  <Controller
          control={control}
          name="availability"
          render={({ field: { onChange, value }, formState: { errors } }) => (
            <Datepicker
              value={value}
              onChange={onChange}
            />
          )}
  />

@mkbctrl
Copy link
Author

mkbctrl commented Dec 20, 2022 via email

@NoahMLoomis
Copy link
Contributor

@onesine this issue can be closed

@onesine onesine closed this as completed Dec 24, 2022
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

3 participants