Skip to content

Commit

Permalink
[Select][material-ui] Add id to hidden input element (#39414)
Browse files Browse the repository at this point in the history
Co-authored-by: Albert Yu <[email protected]>
  • Loading branch information
DarhkVoyd and mj12albert authored Nov 22, 2023
1 parent 3942945 commit b81119c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/mui-material/src/InputLabel/InputLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ const InputLabelRoot = styled(FormLabel, {
transform: 'translate(14px, -9px) scale(0.75)',
}),
}),
...(ownerState.variant === 'standard' && {
'&:not(label) + div': {
marginTop: 16,
},
}),
}));

const InputLabel = React.forwardRef(function InputLabel(inProps, ref) {
Expand Down
4 changes: 3 additions & 1 deletion packages/mui-material/src/Select/SelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {

const listboxId = useId();

const hiddenInputId = useId();

return (
<React.Fragment>
<SelectSelect
Expand Down Expand Up @@ -523,7 +525,7 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {
<SelectNativeInput
aria-invalid={error}
value={Array.isArray(value) ? value.join(',') : value}
name={name}
name={name ?? hiddenInputId}
ref={inputRef}
aria-hidden
onChange={handleChange}
Expand Down

0 comments on commit b81119c

Please sign in to comment.