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

Take into account implicitly defined types when rendering labels for fields #2502

Merged

Conversation

perrinjerome
Copy link
Contributor

getSchemaType is clever enough to figure out that a schema with
properties or additionalProperties has type "object", even if the
type is not explicitly defined, but getDisplayLabel does not have the
same logic, which results in displaying the label twice in cases where
the schema was guessed to be object.

Using getSchemaType as well in getDisplayLabel bring consistent
behavior and the label is rendered only once in that case.

Reasons for making this change

fixes #2501

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

`getSchemaType` is clever enough to figure out that a schema with
`properties` or `additionalProperties` has `type` "object", even if the
type is not explicitly defined, but `getDisplayLabel` does not have the
same logic, which results in displaying the label twice in cases where
the schema was guessed to be object.

Using `getSchemaType` as well in `getDisplayLabel` bring consistent
behavior and the label is rendered only once in that case.

Fixes rjsf-team#2501
@epicfaace epicfaace changed the title Don't render label twice with implicit "object" schema Take into account implicitly defined types when rendering labels for fields Aug 5, 2021
Copy link
Member

@epicfaace epicfaace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Note that this should also fix issues with other implicitly defined types (such as {const: true}) and properly display labels in those cases as well.

@epicfaace epicfaace merged commit f8c6850 into rjsf-team:master Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Label is duplicated when type: "object" is missing from schema
2 participants