Skip to content

Commit

Permalink
mui: fix gap in outline when label is hidden (#3984)
Browse files Browse the repository at this point in the history
* mui: fix gap in outline when label is hidden

Passing `label={false}` to the MUI text/select widgets results in a
gap in the widget outline where the label would be.  Instead, to hide
the label without a gap, we must pass `label={undefined}`.

This commit changes the calls to `labelValue(...)` for
BaseInputTemplatea and SelectWidget to return `undefined` when
`"ui:label": false` was specified.

* mui: update test snapshots
  • Loading branch information
drbild authored Dec 1, 2023
1 parent d89367e commit c5c2b27
Show file tree
Hide file tree
Showing 6 changed files with 413 additions and 733 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ should change the heading of the (upcoming) version to include a major version b
-->
# 5.15.0

## @rjsf/mui

- fix gap in text and select widget outlines when `"ui:label": false` is specified.

## @rjsf/utils

- Added an experimental flag `allOf` to `experimental_defaultFormStateBehavior` for populating defaults when using `allOf` schemas [#3969](https://github.com/rjsf-team/react-jsonschema-form/pull/3969)
Expand Down
2 changes: 1 addition & 1 deletion packages/mui/src/BaseInputTemplate/BaseInputTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function BaseInputTemplate<
id={id}
name={id}
placeholder={placeholder}
label={labelValue(label || undefined, hideLabel, false)}
label={labelValue(label || undefined, hideLabel, undefined)}
autoFocus={autofocus}
required={required}
disabled={disabled || readonly}
Expand Down
2 changes: 1 addition & 1 deletion packages/mui/src/SelectWidget/SelectWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function SelectWidget<
<TextField
id={id}
name={id}
label={labelValue(label || undefined, hideLabel, false)}
label={labelValue(label || undefined, hideLabel, undefined)}
value={!isEmpty && typeof selectedIndexes !== 'undefined' ? selectedIndexes : emptyValue}
required={required}
disabled={disabled || readonly}
Expand Down
Loading

0 comments on commit c5c2b27

Please sign in to comment.