Skip to content

Commit e712241

Browse files
committed
fix: prevent duplicate checkbox description rendering across themes (#4742)
1 parent 4e8236f commit e712241

File tree

27 files changed

+4062
-4067
lines changed

27 files changed

+4062
-4067
lines changed

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,43 @@ should change the heading of the (upcoming) version to include a major version b
1717
-->
1818
# 6.0.0
1919

20+
## @rjsf/shadcn
21+
22+
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
23+
24+
## @rjsf/semantic-ui
25+
26+
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
27+
28+
## @rjsf/primereact
29+
30+
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
31+
32+
## @rjsf/mui
33+
34+
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
35+
36+
## @rjsf/mantine
37+
38+
- Updated `CheckboxWidget` to handle label and description rendering consistently, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
39+
40+
## @rjsf/fluentui-rc
41+
42+
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
43+
44+
## @rjsf/chakra-ui
45+
46+
- Updated `CheckboxWidget` to handle label and description rendering consistently, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
47+
48+
## @rjsf/antd
49+
50+
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
51+
2052
## @rjsf/core
2153

54+
- Fixed duplicate label and description rendering in `CheckboxWidget` by conditionally rendering them based on widget type
55+
- Updated `CheckboxWidget` to handle label and description rendering consistently
56+
- Modified `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
2257
- Updated `SchemaField` to add a new optional property `childFieldPathId` to the `FieldComponent` render to prevent duplicate ids, fixing (#4819)[https://github.com/rjsf-team/react-jsonschema-form/issues/4819]
2358
- Also updated `ObjectField` and `ArrayField` to make children use the `childFieldPathId` if present, falling back to the `fieldPathId` if not
2459

packages/antd/src/templates/FieldTemplate/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export default function FieldTemplate<
5656
} = formContext as GenericObjectType;
5757

5858
const uiOptions = getUiOptions<T, S, F>(uiSchema);
59+
5960
const WrapIfAdditionalTemplate = getTemplate<'WrapIfAdditionalTemplate', T, S, F>(
6061
'WrapIfAdditionalTemplate',
6162
registry,
@@ -79,7 +80,7 @@ export default function FieldTemplate<
7980
descriptionProps.extra = descriptionNode;
8081
break;
8182
}
82-
83+
const isCheckbox = uiOptions.widget === 'checkbox';
8384
return (
8485
<WrapIfAdditionalTemplate
8586
classNames={classNames}
@@ -101,7 +102,7 @@ export default function FieldTemplate<
101102
hasFeedback={schema.type !== 'array' && schema.type !== 'object'}
102103
help={(!!rawHelp && help) || (rawErrors?.length ? errors : undefined)}
103104
htmlFor={id}
104-
label={displayLabel && label}
105+
label={displayLabel && !isCheckbox && label}
105106
labelCol={labelCol}
106107
required={required}
107108
style={wrapperStyle}

packages/antd/test/__snapshots__/Array.test.tsx.snap

Lines changed: 754 additions & 754 deletions
Large diffs are not rendered by default.

packages/antd/test/__snapshots__/Form.test.tsx.snap

Lines changed: 1548 additions & 1548 deletions
Large diffs are not rendered by default.

packages/antd/test/__snapshots__/GridSnap.test.tsx.snap

Lines changed: 692 additions & 692 deletions
Large diffs are not rendered by default.

packages/antd/test/__snapshots__/Object.test.tsx.snap

Lines changed: 651 additions & 651 deletions
Large diffs are not rendered by default.

packages/chakra-ui/src/CheckboxWidget/CheckboxWidget.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
StrictRJSFSchema,
1111
RJSFSchema,
1212
FormContextType,
13+
getUiOptions,
1314
} from '@rjsf/utils';
1415

1516
import { Field } from '../components/ui/field';
@@ -46,7 +47,9 @@ export default function CheckboxWidget<
4647
registry,
4748
options,
4849
);
49-
const description = options.description || schema.description;
50+
const uiOptions = getUiOptions(uiSchema);
51+
const isCheckbox = uiOptions.widget === 'checkbox';
52+
const description = isCheckbox ? undefined : (options.description ?? schema.description);
5053

5154
const _onChange = ({ checked }: CheckboxCheckedChangeDetails) => onChange(checked);
5255
const _onBlur = ({ target }: FocusEvent<HTMLInputElement | any>) => onBlur(id, target && target.checked);

0 commit comments

Comments
 (0)