-
Notifications
You must be signed in to change notification settings - Fork 33
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
Default value is not cloned deeply as the original object type #268
Comments
Sounds fair enough. I think I'd like to default to the current implementation and let people pass a custom Feel free to raise a PR |
I would, but your project and my fork have different changes because of all other pull requests I created and which are not merged. I fixed this issues on my fork on this branch: If you have any idea how to get only the 3 changes without making a new fork, feel free to tell me. |
PR is available #270 |
🎉 This issue has been resolved in version 6.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The default value is not cloned deeply as the original type e.g. Date or any other object. The copy is made by the following code:
const defaultValues: FormInterface = deepCopy(formGroup.value);
and the deepCopy method is implemented like:
export const deepCopy = (value: T): T => JSON.parse(JSON.stringify(value));
This is not a deepy copy of an object. The object is transformed to an string or JSON. If the form value type is a Date and you pass a new Date() as default value the inner value is a string. Thats not correct. In this case the moste date pickers handles the inner value as a Date object.
We should use deepCopy from lodash or any other library which makes a deep object copy.
The text was updated successfully, but these errors were encountered: