Skip to content

Commit 2ac8e94

Browse files
Fix 4134 by filtering out bad DOM props (#4140)
Fixes: #4134 by updating the spreading of props onto the `TextField` to remove bad DOM fields - In `@rjsf/mui`, updated `SelectField` and `BaseInputTemplate` to filter out `errorSchema` and `autocomplete` from the `textFieldProps` before they are spread onto `TextField` - Updated `CHANGELOG.md` accordingly, moving `@rjsf/antd` above `@rjsf/core`
1 parent 88a9407 commit 2ac8e94

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,23 @@ should change the heading of the (upcoming) version to include a major version b
1818

1919
# 5.18.0
2020

21+
## @rjsf/antd
22+
- Fix issue where the theme provided by the ConfigProvider under antd v5 wasn't respected thereby rendering the form items unusable under dark themes [#4129](https://github.com/rjsf-team/react-jsonschema-form/issues/4129)
23+
2124
## @rjsf/core
2225

2326
- Fix Error state not resetting when schema changes [#4079](https://github.com/rjsf-team/react-jsonschema-form/issues/4079)
2427

28+
## @rjsf/mui
29+
30+
- Fixed the `SelectWidget` and `BaseInputTemplate` to filter out `errorSchema` and `autocomplete` from the `textFieldProps` being spread onto the `TextField`, fixing [#4134](https://github.com/rjsf-team/react-jsonschema-form/issues/4134)
31+
2532
## @rjsf/utils
2633

2734
- Added a new `skipEmptyDefault` option in `emptyObjectFields`, fixing [#3880](https://github.com/rjsf-team/react-jsonschema-form/issues/3880)
2835
- Added a new `computeSkipPopulate` option in `arrayMinItems`, allowing custom logic to skip populating arrays with default values, implementing [#4121](https://github.com/rjsf-team/react-jsonschema-form/pull/4121).
2936
- Fixed bug where the string `"\</strong>"` would get printed next to filenames when uploading files, and restored intended bolding of filenames fixing [#4120](https://github.com/rjsf-team/react-jsonschema-form/issues/4120).
3037

31-
## @rjsf/antd
32-
- Fix issue where the theme provided by the ConfigProvider under antd v5 wasn't respected thereby rendering the form items unusable under dark themes [#4129](https://github.com/rjsf-team/react-jsonschema-form/issues/4129)
33-
3438
## Dev / docs / playground
3539

3640
- Updated the documentation to describe how to use the `skipEmptyDefault` option.

packages/mui/src/BaseInputTemplate/BaseInputTemplate.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export default function BaseInputTemplate<
4545
schema,
4646
uiSchema,
4747
rawErrors = [],
48+
errorSchema,
4849
formContext,
4950
registry,
5051
InputLabelProps,

packages/mui/src/SelectWidget/SelectWidget.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default function SelectWidget<
3838
onChange,
3939
onBlur,
4040
onFocus,
41+
errorSchema,
4142
rawErrors = [],
4243
registry,
4344
uiSchema,
@@ -59,6 +60,7 @@ export default function SelectWidget<
5960
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement>) =>
6061
onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, optEmptyVal));
6162
const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, multiple);
63+
const { InputLabelProps, SelectProps, autocomplete, ...textFieldRemainingProps } = textFieldProps;
6264

6365
return (
6466
<TextField
@@ -69,19 +71,20 @@ export default function SelectWidget<
6971
required={required}
7072
disabled={disabled || readonly}
7173
autoFocus={autofocus}
74+
autoComplete={autocomplete}
7275
placeholder={placeholder}
7376
error={rawErrors.length > 0}
7477
onChange={_onChange}
7578
onBlur={_onBlur}
7679
onFocus={_onFocus}
77-
{...(textFieldProps as TextFieldProps)}
80+
{...(textFieldRemainingProps as TextFieldProps)}
7881
select // Apply this and the following props after the potential overrides defined in textFieldProps
7982
InputLabelProps={{
80-
...textFieldProps.InputLabelProps,
83+
...InputLabelProps,
8184
shrink: !isEmpty,
8285
}}
8386
SelectProps={{
84-
...textFieldProps.SelectProps,
87+
...SelectProps,
8588
multiple,
8689
}}
8790
aria-describedby={ariaDescribedByIds<T>(id)}

0 commit comments

Comments
 (0)