[Feature Request] [form] indication whether form changes after prefill #552
Replies: 6 comments
-
I assume that after the user manually undos changes, the form will still be in dirty state? We do store a protected |
Beta Was this translation helpful? Give feedback.
-
Yes the form is still in a dirty state, I think that's correct. But it would be useful to have a way to detect whether there was any change in the input values from the prefilled state. This comparison can get pretty tricky, but each form element could have a different comparison method. |
Beta Was this translation helpful? Give feedback.
-
Alright. Pseudo code would probable be: // InteractionStateMixin + FormGroup
get hasValueChangeSinceInit() {
return deepComparison(this._initialModelValue, this.modelValue);
} |
Beta Was this translation helpful? Give feedback.
-
do you think this will be possible from a form level? maybe it should delegate comparison to the fields like the other properties? then each field can decide how the comparison should happen |
Beta Was this translation helpful? Give feedback.
-
It works on every FormControl (== fieldset/field). _initalModelValue is already delegated: get _initialModelValue() {
return this._getFromAllFormElements('_initialModelValue');
} https://github.com/ing-bank/lion/blob/master/packages/fieldset/src/LionFieldset.js#L439 But of course you can delegate on the Fieldset (from which the LionForm extends) like: return this._getFromAllFormElements('hasValueChangeSinceInit'); |
Beta Was this translation helpful? Give feedback.
-
I like the idea, I would go with Closing as enhancement with votes needed. Our workflow with enhancements is that we close them and have people vote on them, then we sort our enhancements by most votes to see which ones should be prioritized: https://github.com/ing-bank/lion/issues?q=is%3Aissue+is%3Aclosed+label%3Aenhancement+sort%3Areactions-%2B1-desc |
Beta Was this translation helpful? Give feedback.
-
When submitting a form, we sometimes need to take a different action based on whether the user actually made any changes to the form. When we find a solution for #547 we can use the dirty/prefilled state for this.
A more advanced scenario is when a user made some changes, but then undos their changes and the form is back to the initial state it started in. It would be useful to be able to detect this state.
Would this be possible to implement?
Beta Was this translation helpful? Give feedback.
All reactions