Skip to content

Commit

Permalink
Fix 4134 by filtering out bad DOM props (rjsf-team#4140)
Browse files Browse the repository at this point in the history
Fixes: rjsf-team#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`
  • Loading branch information
heath-freenome committed Mar 22, 2024
1 parent 88a9407 commit 2ac8e94
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `"\</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).

## @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.
Expand Down
1 change: 1 addition & 0 deletions packages/mui/src/BaseInputTemplate/BaseInputTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default function BaseInputTemplate<
schema,
uiSchema,
rawErrors = [],
errorSchema,
formContext,
registry,
InputLabelProps,
Expand Down
9 changes: 6 additions & 3 deletions packages/mui/src/SelectWidget/SelectWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function SelectWidget<
onChange,
onBlur,
onFocus,
errorSchema,
rawErrors = [],
registry,
uiSchema,
Expand All @@ -59,6 +60,7 @@ export default function SelectWidget<
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement>) =>
onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, optEmptyVal));
const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, multiple);
const { InputLabelProps, SelectProps, autocomplete, ...textFieldRemainingProps } = textFieldProps;

return (
<TextField
Expand All @@ -69,19 +71,20 @@ export default function SelectWidget<
required={required}
disabled={disabled || readonly}
autoFocus={autofocus}
autoComplete={autocomplete}
placeholder={placeholder}
error={rawErrors.length > 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<T>(id)}
Expand Down

0 comments on commit 2ac8e94

Please sign in to comment.