diff --git a/CHANGELOG.md b/CHANGELOG.md index 785b6b3ec0..a00dcdc2d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ should change the heading of the (upcoming) version to include a major version b ## @rjsf/antd - Fix [#3608](https://github.com/rjsf-team/react-jsonschema-form/issues/3608) by ensuring the root field is always wrapped in Form.Item +- Fix [#3594](https://github.com/rjsf-team/react-jsonschema-form/issues/3594) by removing the duplicate title for `SelectWidget` and description for `CheckboxWidget` ## @rjsf/core diff --git a/packages/antd/src/widgets/CheckboxWidget/index.tsx b/packages/antd/src/widgets/CheckboxWidget/index.tsx index a71dd3ea43..a477501707 100644 --- a/packages/antd/src/widgets/CheckboxWidget/index.tsx +++ b/packages/antd/src/widgets/CheckboxWidget/index.tsx @@ -2,8 +2,6 @@ import { FocusEvent } from 'react'; import Checkbox, { CheckboxChangeEvent } from 'antd/lib/checkbox'; import { ariaDescribedByIds, - descriptionId, - getTemplate, labelValue, FormContextType, RJSFSchema, @@ -22,29 +20,8 @@ export default function CheckboxWidget< S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any >(props: WidgetProps) { - const { - autofocus, - disabled, - formContext, - id, - label, - hideLabel, - onBlur, - onChange, - onFocus, - readonly, - value, - registry, - options, - schema, - uiSchema, - } = props; + const { autofocus, disabled, formContext, id, label, hideLabel, onBlur, onChange, onFocus, readonly, value } = props; const { readonlyAsDisabled = true } = formContext as GenericObjectType; - const DescriptionFieldTemplate = getTemplate<'DescriptionFieldTemplate', T, S, F>( - 'DescriptionFieldTemplate', - registry, - options - ); const handleChange = ({ target }: CheckboxChangeEvent) => onChange(target.checked); @@ -58,33 +35,18 @@ export default function CheckboxWidget< onBlur: !readonly ? handleBlur : undefined, onFocus: !readonly ? handleFocus : undefined, }; - const description = options.description ?? schema.description; - return ( - <> - {!hideLabel && !!description && ( -
- (id)} - description={description} - schema={schema} - uiSchema={uiSchema} - registry={registry} - /> -
- )} - (id)} - > - {labelValue(label, hideLabel, '')} - - + (id)} + > + {labelValue(label, hideLabel, '')} + ); } diff --git a/packages/antd/src/widgets/SelectWidget/index.tsx b/packages/antd/src/widgets/SelectWidget/index.tsx index 2ff7c5914e..6c64655564 100644 --- a/packages/antd/src/widgets/SelectWidget/index.tsx +++ b/packages/antd/src/widgets/SelectWidget/index.tsx @@ -3,8 +3,6 @@ import { ariaDescribedByIds, enumOptionsIndexForValue, enumOptionsValueForIndex, - getTemplate, - titleId, FormContextType, GenericObjectType, RJSFSchema, @@ -31,8 +29,6 @@ export default function SelectWidget< disabled, formContext = {} as F, id, - label, - hideLabel, multiple, onBlur, onChange, @@ -40,13 +36,9 @@ export default function SelectWidget< options, placeholder, readonly, - registry, - schema, - uiSchema, value, }: WidgetProps) { const { readonlyAsDisabled = true } = formContext as GenericObjectType; - const TitleFieldTemplate = getTemplate<'TitleFieldTemplate', T, S, F>('TitleFieldTemplate', registry, options); const { enumOptions, enumDisabled, emptyValue } = options; @@ -74,37 +66,32 @@ export default function SelectWidget< name: id, }; return ( - <> - {!hideLabel && !!label && ( - (id)} title={label} schema={schema} uiSchema={uiSchema} registry={registry} /> - )} - - + ); } diff --git a/packages/antd/test/__snapshots__/Array.test.tsx.snap b/packages/antd/test/__snapshots__/Array.test.tsx.snap index dfa4b9ff37..2668292dcf 100644 --- a/packages/antd/test/__snapshots__/Array.test.tsx.snap +++ b/packages/antd/test/__snapshots__/Array.test.tsx.snap @@ -2530,14 +2530,6 @@ exports[`with title and description checkboxes 1`] = `
-
-
-
-