Skip to content

Commit

Permalink
fix: make dirty on field a computed value
Browse files Browse the repository at this point in the history
  • Loading branch information
YannicEl committed Jan 2, 2024
1 parent c5627f4 commit 6b4a4af
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions packages/lib/src/useField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,15 @@ export function useField<T>(
const disable = () => (disabled.value = true);
const enable = () => (disabled.value = false);

const dirty = ref(false);
const dirty = computed(() => value.value !== initialValue);
const pristine = computed(() => !dirty.value);
watch(value, (newValue) => {
if (newValue !== initialValue) dirty.value = true;
});

const touched = ref(false);
const untouched = computed(() => !touched.value);

function reset(): void {
value.value = initialValue;
disabled.value = false;
dirty.value = false;
touched.value = false;
}

Expand Down

0 comments on commit 6b4a4af

Please sign in to comment.