-
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
allow Material-ui boolean checkboxes to have descriptions #2330
Conversation
Is the correct fix to this issue, to add the schema.description check in CheckboxWidget? this appears to be a problem in material-ui, antd, and sematic-ui as well. The current solution does currently make it double appear in default theme. This seems to be caused by the WrapIfAdditional and DefaultTemplate adding the description as well. |
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.
Are you sure this is the right approach? This same function appears in utils.js --
react-jsonschema-form/packages/core/src/utils.js
Lines 389 to 407 in 1ae4f39
export function getDisplayLabel(schema, uiSchema, rootSchema) { | |
const uiOptions = getUiOptions(uiSchema); | |
let { label: displayLabel = true } = uiOptions; | |
if (schema.type === "array") { | |
displayLabel = | |
isMultiSelect(schema, rootSchema) || | |
isFilesArray(schema, uiSchema, rootSchema); | |
} | |
if (schema.type === "object") { | |
displayLabel = false; | |
} | |
if (schema.type === "boolean" && !uiSchema["ui:widget"]) { | |
displayLabel = false; | |
} | |
if (uiSchema["ui:field"]) { | |
displayLabel = false; | |
} | |
return displayLabel; | |
} |
Hi @epicfaace, see my comment above. into the CheckBox widget itself. but the problem is in 2 other theme libraries as well. So I was looking at a more global solution to keep the pattern consistent across the various themes. From a library design perspective, do you want widgets to be responsible for their own descriptions? or allow WrapIfAdditional pattern? Should I move ahead with only the material-ui fix to move this forward? |
Yeah, let's move ahead with the material-ui fix to move this forward for now. Unfortunately, as you note, there is an inconsistency between themes in which some themes have widgets responsible for their own descriptions, while others don't. Maybe we can consider improving that to make it consistent in a future major version release. |
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.
Thanks, can you add a snapshot test for this as well?
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.
Looks good -- thanks!
Sorry, @cfluke-twilio I'm a bit confused. Why do descriptions work for the TextWidget in material-ui, even though there's no code like the one in this PR for TextWidget? |
TextWidget is calling the getDisplayLabel from the core utils here The core utils has getDisplayLabel return false for checkboxes. |
bump |
We have created a lot of hacky workarounds to overcome all of these weird exceptions. Maybe we should consider adding to your core, as we depend on it sooooo much @epicfaace. Thanks for all the hard work. I do get the feeling that the maintainers are all paid volunteers, and it would be awesome if this project could get adopted by a major corp to start funding development. |
…ss hidden prop to ObjectFieldTemplate (#2405) * material-ui: hide grid for hidden fields Implementations follows the one that already exists for ant design. Closes #1974 * Update test snapshot to latest master * Add comment * Move ui:widget evaluation into core * Add test for hidden in antd * Hide hidden fields in bootstrap Closes #2175 * Improve tests * Remove whitespace for hidden in fluent-ui * Update custom-templates.md Co-authored-by: Ashwin Ramaswami <aramaswamis@gmail.com>
Bumps [postcss](https://github.com/postcss/postcss) from 7.0.27 to 7.0.36. - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](postcss/postcss@7.0.27...7.0.36) --- updated-dependencies: - dependency-name: postcss dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
* Deploy canary builds to npm from master * fix typo * use npx
* Add null check to componentDidUpdate * added test case to altdatewidget
* Add null check to componentDidUpdate * added test case to altdatewidget * change npm install to npm ci in release pipeline Co-authored-by: Ashwin Ramaswami <aramaswamis@gmail.com>
It seems like 3.0.0 doesn't work if you use the UMD bundle. Reverting it to 2.5.1 for now to address #2447
Clarify based on #2436 (comment)
* Restore global external for UMD hosted in CDN * Update webpack.config.dist.js * Update docs/main.js Co-authored-by: Ashwin Ramaswami <aramaswamis@gmail.com>
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2.1.5 to 2.3.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](actions/setup-node@v2.1.5...v2.3.0) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This reverts commit 8e6b8da.
Reasons for making this change
Descriptions for boolean checkboxes were being ignored.
If this is related to existing tickets, include links to them as well. Use the syntax
fixes #[issue number]
(ex:fixes #123
).fixes #2203
Checklist
Deploy preview
Once CI finishes, you should be able to view a deploy preview of the playground from this PR at this link: https://deploy-preview-[PR_NUMBER]--rjsf.netlify.app/