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

JSONSchema oneOf properties with initial values #2195

Closed
jma opened this issue Apr 22, 2020 · 3 comments · Fixed by #2196
Closed

JSONSchema oneOf properties with initial values #2195

jma opened this issue Apr 22, 2020 · 3 comments · Fixed by #2196
Labels

Comments

@jma
Copy link

jma commented Apr 22, 2020

Description
When the editor with a JSONSchema oneOf property is loaded with an initial model, the wrong option is selected.

Minimal Reproduction

In this example, the model value correspond to only one option: the second. But the editor select the first option.
https://stackblitz.com/edit/angular-157bka?file=src%2Fassets%2Fjson-schema%2FoneOf.json

Your Environment

  • Angular version: 7.2.16
  • Formly version: 5.5.15

Additional context
This is probably due to the fact that the two oneOf options have the same name property. This is probably not easy to solve as the additionalProperties should be checked.

@aitboudad
Copy link
Member

The following PR #2196 improves the select oneOf which takes account of the number of matched model properties (the highest is selected).

@aitboudad
Copy link
Member

oneOf try to select the valid option first so if you want to rely on additionalProperties, just define additionalProperties validator in your project and it should work as expected without waiting for the above fix.

@aitboudad
Copy link
Member

This issue has been fixed and released as part of v5.6.0 release.

Please let us know, in case you are still encountering a similar issue/problem.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants