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

invalid, errors and dirty readable stores from formup do not show correct values #105

Open
kimskovhusandersen opened this issue Mar 1, 2021 · 0 comments

Comments

@kimskovhusandersen
Copy link
Contributor

Hi Sascha,

I'm displaying a form with a single field.

When selecting the field, the $dirty store does not update. It remains an empty object.
When I enter a text and delete it again, the $errors and $invalid store do not update either. Both remain empty objects.

{ "values": { "bpm_comment": "" }, "invalid": {}, "errors": {}, "dirty": {} }

I'm using

  • svelte-formup version 0.6.2,
  • svelte version 3.32.0, and
  • yup version 0.30.0

Here is my code:

<script lang="ts">
  import { object, string } from 'yup'
  import { formup } from 'svelte-formup'

  const schema = object().shape({
    bpm_comment: string().required(),
  })

  const { values, validate, invalid, errors, dirty, validity } = formup({
    getInitialValues: () => ({
      bpm_comment: undefined,
    }),
    validateOn: ['input', 'change'],
    schema,
    validateInitialValues: true,
    async onSubmit(data, _) {
      console.log({ data })
    },
  })

</script>

<form use:validate role="form">
  <div use:validity>
    <textarea
      id={'bpm_comment'}
      name="bpm_comment"
      label="Comment (optional)"
      rows={3}
      bind:value={$values.bpm_comment} />
  </div>
  <p>
    <button type="submit">Submit</button>  
    <button type="reset">reset</button></p>
</form>

{JSON.stringify({ values: $values, invalid: $invalid, errors: $errors, dirty: $dirty }, null, 4)}
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

1 participant