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

ui:options not behaving as expected from the documentation #2535

Closed
3 tasks done
bejito opened this issue Sep 2, 2021 · 5 comments · Fixed by #3191
Closed
3 tasks done

ui:options not behaving as expected from the documentation #2535

bejito opened this issue Sep 2, 2021 · 5 comments · Fixed by #3191
Assignees
Labels
bug core labelOrDescription Relating to labels and descriptions of fields in the form uiSchema

Comments

@bejito
Copy link

bejito commented Sep 2, 2021

Prerequisites

Description

Hello ! I'm sorry if I missed something, but in the documentation it seems to state that {"ui:options": {[property]: [value]}} and {"ui:[property]": value} are equivalent. When I try this locally or on your playground though, I'm having a different behaviour where the ui:options does not seem to be read.

Steps to Reproduce

https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6e30sInNjaGVtYSI6eyJ0aXRsZSI6IkEgcmVnaXN0cmF0aW9uIGZvcm0iLCJkZXNjcmlwdGlvbiI6IkEgc2ltcGxlIGZvcm0gZXhhbXBsZS4iLCJ0eXBlIjoib2JqZWN0IiwicHJvcGVydGllcyI6eyJuYW1lIjp7InR5cGUiOiJzdHJpbmcifX19LCJ1aVNjaGVtYSI6eyJ1aTpvcHRpb25zIjp7InRpdGxlIjoiVGl0bGUiLCJkZXNjcmlwdGlvbiI6IkRlc2NyaXB0aW9uIn0sIm5hbWUiOnsidWk6b3B0aW9ucyI6eyJ0aXRsZSI6IkN1c3RvbSB0aXRsZSIsImRlc2NyaXB0aW9uIjoiY3VzdG9tIGRlc2MifX19LCJ0aGVtZSI6ImRlZmF1bHQiLCJsaXZlU2V0dGluZ3MiOnsidmFsaWRhdGUiOmZhbHNlLCJkaXNhYmxlIjpmYWxzZSwib21pdEV4dHJhRGF0YSI6ZmFsc2UsImxpdmVPbWl0IjpmYWxzZX19

Expected behavior

uiSchema["ui:options].title and uiSchema["ui:options].description should be taken into account and override the field title that is in the json schema

Actual behavior

uiSchema["ui:options"] seem to be ignored for these ui options.

Version

3.1.0

@bejito bejito changed the title ui:options not behaving ui:options not behaving as expected fromo the documentation Sep 2, 2021
@epicfaace
Copy link
Member

epicfaace commented Sep 2, 2021 via email

@bejito bejito changed the title ui:options not behaving as expected fromo the documentation ui:options not behaving as expected from the documentation Sep 2, 2021
@bejito
Copy link
Author

bejito commented Sep 2, 2021

It seems they are hardcoded in the core library indeed, e.g.
https://github.com/rjsf-team/react-jsonschema-form/blob/3ec17f1c0f/packages/core/src/components/fields/ObjectField.js#L224
https://github.com/rjsf-team/react-jsonschema-form/blob/3ec17f1c0f/packages/core/src/components/fields/SchemaField.js#L290

I'm not very familiar with the code, but there seems to be a util function to merge the ui options from the different locations. I guess that should be used everywhere we need to read from the uiSchema ?

@epicfaace
Copy link
Member

Yes, that seems like the right solution. Would you be willing to make a PR that fixes this issue wherever it's found in the codebase?

@bejito
Copy link
Author

bejito commented Sep 2, 2021

I don't have enough knowledge of the codebase and bandwidth right now to do this unfortunately. Especially since it is easy to work around this issue by directly using uiSchema["ui:{prop}"] for now. If no one touches this in a while, I'll try to find some time

@newt10 newt10 added bug uiSchema labelOrDescription Relating to labels and descriptions of fields in the form core labels Sep 2, 2021
@newt10 newt10 linked a pull request Sep 3, 2021 that will close this issue
7 tasks
@newt10
Copy link
Collaborator

newt10 commented Sep 3, 2021

I have created a fix for this waiting in PR , @bejito it would be great if you could check it out as well.

@newt10 newt10 self-assigned this Sep 3, 2021
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
- 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
- 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 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
- 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 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
bug core labelOrDescription Relating to labels and descriptions of fields in the form uiSchema
Projects
None yet
3 participants