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

Pass schema to Title/Description Templates via props #3176

Closed
1 task done
nickgros opened this issue Oct 5, 2022 · 0 comments · Fixed by #3191
Closed
1 task done

Pass schema to Title/Description Templates via props #3176

nickgros opened this issue Oct 5, 2022 · 0 comments · Fixed by #3191
Assignees
Labels
feature Is a feature request

Comments

@nickgros
Copy link
Contributor

nickgros commented Oct 5, 2022

Prerequisites

What theme are you using?

core

Is your feature request related to a problem? Please describe.

I would like my custom title/description fields and templates to include details from the schema (e.g. I want to explicitly tell the user that the field is a "number" type, but I can't do that by just overriding a template.

Describe the solution you'd like

Add schema as a prop to

  • TitleFieldProps
  • DescriptionFieldProps

and pass it along.

Describe alternatives you've considered

I currently replace the DescriptionField and ArrayFieldDescriptionTemplate with my own custom component that utilizes the schema inside of my custom FieldTemplate and ArrayFieldTemplate

@nickgros nickgros added needs triage Initial label given, to be assigned correct labels and assigned feature Is a feature request labels Oct 5, 2022
@nickgros nickgros self-assigned this Oct 5, 2022
@heath-freenome heath-freenome removed the needs triage Initial label given, to be assigned correct labels and assigned label Oct 7, 2022
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Oct 10, 2022
…rray description and title

Fix rjsf-team#2535 by reimplementing rjsf-team#2537. Also fixes rjsf-team#3176 by passing uiSchema and schema to the description and title templates.
- In `@rjsf/utils`, updated the props for the description and title templates to add `schema`
  - Also made the `title` and `description` for the array field description and title props as optional
- In all of the themes, ensured that the `schema` is now passed to the all the calls to the description and title templates
  - With the exception of the `antd` theme, removed the logic for conditionally rendering the `ArrayFieldDescriptionTemplate` since that template already handles the condition
  - Deleted the tests for `DescriptionField` and `TitleField` in the `bootstrap-4` theme because they broke, and are redundant anyway given the other tests
- In `@rjsf/core`, updated the `ArrayFieldDescriptionTemplate` and `ArrayFieldTitleTemplate` to not render the template when `ui:label` is false
  - Updated the tests to verify this change
- Updated the `custom-templates.md` file to document the new `schema` prop and add the `uiSchema` prop docs where missing
- Updated the `contributing.md` file to improve developer documentation
- Updated the `CHANGELOG.md` file accordingly
heath-freenome added a commit that referenced this issue Oct 10, 2022
…ription and title (#3191)

Fix #2535 by reimplementing #2537. Also fixes #3176 by passing uiSchema and schema to the description and title templates.
- In `@rjsf/utils`, updated the props for the description and title templates to add `schema`
  - Also made the `title` and `description` for the array field description and title props as optional
- In all of the themes, ensured that the `schema` is now passed to the all the calls to the description and title templates
  - With the exception of the `antd` theme, removed the logic for conditionally rendering the `ArrayFieldDescriptionTemplate` since that template already handles the condition
  - Deleted the tests for `DescriptionField` and `TitleField` in the `bootstrap-4` theme because they broke, and are redundant anyway given the other tests
- In `@rjsf/core`, updated the `ArrayFieldDescriptionTemplate` and `ArrayFieldTitleTemplate` to not render the template when `ui:label` is false
  - Updated the tests to verify this change
- Updated the `custom-templates.md` file to document the new `schema` prop and add the `uiSchema` prop docs where missing
- Updated the `contributing.md` file to improve developer documentation
- Updated the `CHANGELOG.md` file accordingly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is a feature request
Projects
None yet
2 participants