Skip to content

[BUG] Field is marked as dirty if checkOnInit is set to true #83

Open
@tbydza

Description

@tbydza

If checkOnInit option of field() function is set to true, the initial validation immediately sets dirty flag to true.
The field is then marked as dirty without any user input or without manually setting a value.

Demo for demonstration: REPL demo

<script>
  import { form, field } from 'svelte-forms';
  import { required } from 'svelte-forms/validators';

  const input1 = field('input1', '', [required()], {checkOnInit: false});
  const input2 = field('input2', '', [required()], {checkOnInit: true});

  input2.subscribe(console.log)
</script>


<section>
  checkOnInit: false
  <input type="text" bind:value={$input1.value}/>
  dirty: {$input1.dirty}
  <br>
  checkOnInit: true
  <input type="text" bind:value={$input2.value}/>
  dirty: {$input2.dirty}
</section>

dirty

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions