adfinis / ember-validated-form

Easily create forms with client side validations.
https://adfinis.github.io/ember-validated-form
MIT License
69 stars 32 forks source link

Make setDirty more clever #93

Open makepanic opened 6 years ago

makepanic commented 6 years ago

Right now setDirty always sets the dirty property to true. We could make it more clever to only dirty the form if the changeset isDirty is true.

This also helps to prevents validating the form when removing focus of a form that uses autofocus to focus the first input element.

If you're fine with this solution, I could open a PR.

czosel commented 6 years ago

Hi @makepanic, that would mean that focussing and un-focussing an input element without changing it wouldn't mark it dirty, right? I think that's not great for UX - for example, you wouldn't immediately see required field validations anymore.

makepanic commented 6 years ago

I guess you're right that it doesn't make sense for all forms.

For our case we have a form that takes focus and only validates when changing the value or once it's submitted. Required fields are visually marked and simply focus/blur isn't triggering the validation.

I guess we can close this issue as it's possible to create a validated-input component and simply overwrite the default setDirty implementation to use model.isDirty.

czosel commented 6 years ago

Alright - i'll leave the issue open for a bit anyway. If there's more demand for something like this we could consider adding an option.