fix(striker-ui): pass id to input element in SelectWithLabel

main
Tsu-ba-me 2 years ago committed by digimer
parent 4aa42e680d
commit c85cea0094
  1. 13
      striker-ui/components/SelectWithLabel.tsx

@ -71,15 +71,20 @@ const SelectWithLabel: FC<SelectWithLabelProps> = ({
[createCheckbox, disableItem, hideItem, id],
);
const inputElement = useMemo(() => <OutlinedInput label={label} />, [label]);
const selectId = useMemo(() => `${id}-select-element`, [id]);
const inputElement = useMemo(
() => <OutlinedInput id={id} label={label} />,
[id, label],
);
const labelElement = useMemo(
() =>
label && (
<OutlinedInputLabel htmlFor={id} {...inputLabelProps}>
<OutlinedInputLabel htmlFor={selectId} {...inputLabelProps}>
{label}
</OutlinedInputLabel>
),
[id, inputLabelProps, label],
[inputLabelProps, label, selectId],
);
const menuItemElements = useMemo(
() =>
@ -96,7 +101,7 @@ const SelectWithLabel: FC<SelectWithLabelProps> = ({
<MUIFormControl fullWidth {...formControlProps}>
{labelElement}
<Select
id={id}
id={selectId}
input={inputElement}
multiple={selectMultiple}
name={name}

Loading…
Cancel
Save