From a18307af6ede49a0adda273972db611f5de3c35e Mon Sep 17 00:00:00 2001 From: Heath Chiavettone Date: Fri, 22 Mar 2024 12:58:03 -0700 Subject: [PATCH] Fix 4134 by filtering out bad DOM props 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` --- CHANGELOG.md | 10 +++++++--- .../mui/src/BaseInputTemplate/BaseInputTemplate.tsx | 1 + packages/mui/src/SelectWidget/SelectWidget.tsx | 9 ++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85b6ffd2f7..0b3f674238 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,19 +18,23 @@ should change the heading of the (upcoming) version to include a major version b # 5.18.0 +## @rjsf/antd +- 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) + ## @rjsf/core - Fix Error state not resetting when schema changes [#4079](https://github.com/rjsf-team/react-jsonschema-form/issues/4079) +## @rjsf/mui + +- 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) + ## @rjsf/utils - Added a new `skipEmptyDefault` option in `emptyObjectFields`, fixing [#3880](https://github.com/rjsf-team/react-jsonschema-form/issues/3880) - 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). - Fixed bug where the string `"\"` 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). -## @rjsf/antd -- 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) - ## Dev / docs / playground - Updated the documentation to describe how to use the `skipEmptyDefault` option. diff --git a/packages/mui/src/BaseInputTemplate/BaseInputTemplate.tsx b/packages/mui/src/BaseInputTemplate/BaseInputTemplate.tsx index e62d052f69..8d14f2e3bb 100644 --- a/packages/mui/src/BaseInputTemplate/BaseInputTemplate.tsx +++ b/packages/mui/src/BaseInputTemplate/BaseInputTemplate.tsx @@ -45,6 +45,7 @@ export default function BaseInputTemplate< schema, uiSchema, rawErrors = [], + errorSchema, formContext, registry, InputLabelProps, diff --git a/packages/mui/src/SelectWidget/SelectWidget.tsx b/packages/mui/src/SelectWidget/SelectWidget.tsx index 9fbc4a18eb..5860de2cf6 100644 --- a/packages/mui/src/SelectWidget/SelectWidget.tsx +++ b/packages/mui/src/SelectWidget/SelectWidget.tsx @@ -38,6 +38,7 @@ export default function SelectWidget< onChange, onBlur, onFocus, + errorSchema, rawErrors = [], registry, uiSchema, @@ -59,6 +60,7 @@ export default function SelectWidget< const _onFocus = ({ target: { value } }: FocusEvent) => onFocus(id, enumOptionsValueForIndex(value, enumOptions, optEmptyVal)); const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple); + const { InputLabelProps, SelectProps, autocomplete, ...textFieldRemainingProps } = textFieldProps; return ( 0} onChange={_onChange} onBlur={_onBlur} onFocus={_onFocus} - {...(textFieldProps as TextFieldProps)} + {...(textFieldRemainingProps as TextFieldProps)} select // Apply this and the following props after the potential overrides defined in textFieldProps InputLabelProps={{ - ...textFieldProps.InputLabelProps, + ...InputLabelProps, shrink: !isEmpty, }} SelectProps={{ - ...textFieldProps.SelectProps, + ...SelectProps, multiple, }} aria-describedby={ariaDescribedByIds(id)}