UNPKG

@modular-forms/solid

Version:

The modular and type-safe form library for SolidJS

23 lines (22 loc) 763 B
import { batch, untrack } from 'solid-js'; import { updateFormDirty } from './updateFormDirty'; /** * Updates the dirty state of a field array. * * @param form The form of the field array. * @param fieldArray The store of the field array. */ export function updateFieldArrayDirty(form, fieldArray) { untrack(() => { // Check if field array is dirty const dirty = fieldArray.startItems.get().join() !== fieldArray.items.get().join(); // Update dirty state of field array if necessary if (dirty !== fieldArray.dirty.get()) { batch(() => { fieldArray.dirty.set(dirty); // Update dirty state of form updateFormDirty(form, dirty); }); } }); }