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

fix: label for checkbox widget #3306

Closed
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -16,6 +16,8 @@ should change the heading of the (upcoming) version to include a major version b

-->
# 5.0.0-beta-15
## @rjsf/semantic-ui
- Fix CheckboxWidget missing label [#3302](https://github.com/rjsf-team/react-jsonschema-form/issues/3302)
jacqueswho marked this conversation as resolved.
Show resolved Hide resolved

# @rjsf/core
- Pass the `schema` along to the `ArrayFieldItemTemplate` as part of the fix for [#3253](https://github.com/rjsf-team/react-jsonschema-form/issues/3253)
Expand Down
38 changes: 19 additions & 19 deletions packages/semantic-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/semantic-ui/package.json
Expand Up @@ -50,7 +50,7 @@
"@types/react-test-renderer": "^17.0.2",
"atob": "^2.0.3",
"dts-cli": "^1.6.0",
"eslint": "^8.26.0",
"eslint": "^8.23.0",
heath-freenome marked this conversation as resolved.
Show resolved Hide resolved
"nanoid": "^3.3.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
6 changes: 1 addition & 5 deletions packages/semantic-ui/src/CheckboxWidget/CheckboxWidget.tsx
Expand Up @@ -17,9 +17,7 @@ function CheckboxWidget(props: WidgetProps) {
options,
onFocus,
formContext,
schema,
uiSchema,
registry,
rawErrors = [],
} = props;
const semanticProps = getSemanticProps({
Expand All @@ -30,8 +28,6 @@ function CheckboxWidget(props: WidgetProps) {
inverted: false,
},
});
const { schemaUtils } = registry;
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
const _onChange = (
_: React.FormEvent<HTMLInputElement>,
data: CheckboxProps
Expand All @@ -52,7 +48,7 @@ function CheckboxWidget(props: WidgetProps) {
onBlur={_onBlur}
onFocus={_onFocus}
required={required}
label={displayLabel ? label || schema.title : false}
label={label || ""}
heath-freenome marked this conversation as resolved.
Show resolved Hide resolved
/>
);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/semantic-ui/test/Form.test.tsx
Expand Up @@ -188,9 +188,10 @@ describe("single fields", () => {
.toJSON();
expect(tree).toMatchSnapshot();
});
test("checkbox field", () => {
test("checkbox field with label", () => {
const schema: RJSFSchema = {
type: "boolean",
title: "test",
heath-freenome marked this conversation as resolved.
Show resolved Hide resolved
};
const tree = renderer
.create(<Form schema={schema} validator={validator} />)
Expand Down
10 changes: 7 additions & 3 deletions packages/semantic-ui/test/__snapshots__/Form.test.tsx.snap
Expand Up @@ -39,7 +39,9 @@ exports[`single fields checkbox field 1`] = `
/>
<label
htmlFor="root"
/>
>

</label>
</div>
</div>
</div>
Expand All @@ -54,7 +56,7 @@ exports[`single fields checkbox field 1`] = `
</form>
`;

exports[`single fields checkbox field 2`] = `
exports[`single fields checkbox field with label 1`] = `
<form
className="ui form rjsf"
noValidate={false}
Expand Down Expand Up @@ -93,7 +95,9 @@ exports[`single fields checkbox field 2`] = `
/>
<label
htmlFor="root"
/>
>
test
</label>
</div>
</div>
</div>
Expand Down