-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Removed throwing error when there's an extraneous property in ui:order #814
Removed throwing error when there's an extraneous property in ui:order #814
Conversation
Can you update the test instead of deleting it ? |
Added tests for orderProperties(). Thanks. |
@@ -218,19 +218,6 @@ describe("ObjectField", () => { | |||
expect(labels).eql(["baz", "bar", "qux", "foo"]); | |||
}); | |||
|
|||
it("should throw when order list contains an extraneous property", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you keep this test please and change the expectation ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
- extranous properties in ui:order not throwing errors rjsf-team/react-jsonschema-form#814 - exported validator instance for customization rjsf-team/react-jsonschema-form#794
When is this getting merged @edi9999 ? |
I personnaly have found that the shown warning is useful, especially when you make typos , for example if I write in my json-schema :
and in my ui-schema :
Maybe this could be an option that you set globally, such as :
|
Oh good point. You just gave me an idea, would it be better to show a warning in the console instead of having the warning inside the form? This way you could easily track any mispelled properties and extraneous properties by looking at your console without breaking the form. What do you think? |
Yes, I think it makes sense to use |
Yes, the warning when you use a property name that doesn't exist can save a lot of aggravation. I understand it isn't really helpful in the case of dynamic schemas with property dependencies, which is why I suggested in #823 that we could maybe loosen the check in only those cases. I'd prefer logic that does the right thing to an option that the user has to know to set. @jaminthorns commented in that issue that |
This would be very helpful for me as I'm starting to get into generating dynamic JSON Schemas based on various rules. I would like to not have to worry about also dynamically generating my UI Schema's |
Perhaps we could just have a
I would suggest a more regex-y |
Ran into a related issue today which is blocking our project, looking for advice. We have two "enum" fields in a section that each have dependencies, when you select the "Other" there is a text entry (this is an extremely common pattern on the web, no?) I have no way of telling
The above results in: Am I missing some more practical way of getting this behavior? Certainly this is pretty common, so I'm thinking maybe dependencies aren't the way to do it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good change, thanks! Sorry we didn't get to merging it earlier.
Reasons for making this change
In current implementation if you use dynamic schema dependencies, you cannot specify dependent fields in 'ui:order' list. It's because if you list such field in 'ui:order' and it is currently not displayed according to it's dependency condition, the error is thrown: 'uiSchema order list does not contain '.
I do not see why we should throw an error instead of just filtering 'ui:order' array to contain fields that are present according to dependency condition. If you cannot order conditional fields along with unconditional, it significantly reduces usefulness of dynamic schema dependency feature.
My solution is to give user the ability to specify all properties in 'ui:order' and just sort them as needed.
Checklist
npm run cs-format
on my branch to conform my code to prettier coding style