react-jsonschema-form
react-jsonschema-form copied to clipboard
New additionalTemplate is called when editing keyValue
Prerequisites
- [X] I have searched the existing issues
- [X] I understand that providing a SSCCE example is tremendously useful to the maintainers.
- [X] I have read the documentation
- [X] Ideally, I'm providing a sample JSFiddle or a shared playground link demonstrating the issue.
What theme are you using?
core
Version
5.2.1
Current Behavior
I've got a object inside items key and an additionalProperties for particular use case.
Behaviour : When I define a default value in items, a new template for additional items is called when I try to edit the key.
Expected Behavior
The expected behavior should be that a new template shouldn't be called.
Steps To Reproduce
https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6eyJtZXJnZSI6W10sImZpcnN0TmFtZSI6IkNodWNrIiwibGFzdE5hbWUiOiJOb3JyaXMiLCJhZ2UiOjc1LCJiaW8iOiJSb3VuZGhvdXNlIGtpY2tpbmcgYXNzZXMgc2luY2UgMTk0MCIsInBhc3N3b3JkIjoibm9uZWVkIiwidGVsZXBob25lIjoiMS04MDAtS0lDS0FTUyJ9LCJzY2hlbWEiOnsidHlwZSI6Im9iamVjdCIsInByb3BlcnRpZXMiOnsibWVyZ2UiOnsidGl0bGUiOiJBbiBhcnJheSIsInR5cGUiOiJhcnJheSIsIml0ZW1zIjp7InRpdGxlIjoiQW4gb2JqZWN0IGl0ZW1zIHdpdGggYWRkaXRpb25hbFByb3BlcnRpZXMga2V5IiwidHlwZSI6Im9iamVjdCIsImRlZmF1bHQiOnsidmFsdWUiOnsia2luZFByb3BlcnR5IjpbXX19LCJhZGRpdGlvbmFsUHJvcGVydGllcyI6eyJ0eXBlIjoib2JqZWN0IiwidGl0bGUiOiJBbiBvYmplY3Qgd2l0aCBhIHByb3BlcnR5IiwicHJvcGVydGllcyI6eyJraW5kUHJvcGVydHkiOnsidHlwZSI6ImFycmF5IiwiaXRlbXMiOnsidHlwZSI6InN0cmluZyJ9LCJ1bmlxdWVJdGVtcyI6dHJ1ZX19fX19fX0sInVpU2NoZW1hIjp7ImZpcnN0TmFtZSI6eyJ1aTphdXRvZm9jdXMiOnRydWUsInVpOmVtcHR5VmFsdWUiOiIiLCJ1aTpwbGFjZWhvbGRlciI6InVpOmVtcHR5VmFsdWUgY2F1c2VzIHRoaXMgZmllbGQgdG8gYWx3YXlzIGJlIHZhbGlkIGRlc3BpdGUgYmVpbmcgcmVxdWlyZWQiLCJ1aTphdXRvY29tcGxldGUiOiJmYW1pbHktbmFtZSJ9LCJsYXN0TmFtZSI6eyJ1aTphdXRvY29tcGxldGUiOiJnaXZlbi1uYW1lIn0sImFnZSI6eyJ1aTp3aWRnZXQiOiJ1cGRvd24iLCJ1aTp0aXRsZSI6IkFnZSBvZiBwZXJzb24iLCJ1aTpkZXNjcmlwdGlvbiI6IihlYXJ0aCB5ZWFyKSJ9LCJiaW8iOnsidWk6d2lkZ2V0IjoidGV4dGFyZWEifSwicGFzc3dvcmQiOnsidWk6d2lkZ2V0IjoicGFzc3dvcmQiLCJ1aTpoZWxwIjoiSGludDogTWFrZSBpdCBzdHJvbmchIn0sInRlbGVwaG9uZSI6eyJ1aTpvcHRpb25zIjp7ImlucHV0VHlwZSI6InRlbCJ9fX0sInRoZW1lIjoiZGVmYXVsdCIsImxpdmVTZXR0aW5ncyI6eyJzaG93RXJyb3JMaXN0IjoidG9wIiwidmFsaWRhdGUiOmZhbHNlLCJkaXNhYmxlIjpmYWxzZSwicmVhZG9ubHkiOmZhbHNlLCJvbWl0RXh0cmFEYXRhIjpmYWxzZSwibGl2ZU9taXQiOmZhbHNlfX0=
Environment
- OS:
- Node:
- npm:
Anything else?
No response
@RaphaelSve Wow, nice find! It turns out that our default value generation code is always adding the value to the formData because you have defined it. If you remove the default things work as expected. Unfortunately this means you lose your default value if you need it. Does this help? We have a new feature issue related to disabling not automatically adding defaults, so we are aware of this.
@heath-freenome, Indeed I need to define a default value to push by default a new object property when I press the add button on the array.
@RaphaelSve An alternative would be to add an onChange handler that updated the formData to add the empty array. It requires code, but would avoid the behavior you are seeing
This issue has been automatically marked as possibly close because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.
This issue was closed because of lack of recent activity. Reopen if you still need assistance.