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

Make setDirty more clever #93

Open
makepanic opened this issue Feb 26, 2018 · 3 comments
Open

Make setDirty more clever #93

makepanic opened this issue Feb 26, 2018 · 3 comments

Comments

@makepanic
Copy link
Contributor

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
Copy link
Contributor

czosel commented Feb 26, 2018

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
Copy link
Contributor Author

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
Copy link
Contributor

czosel commented Feb 27, 2018

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.

@czosel czosel reopened this Feb 27, 2018
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

2 participants