Skip to content

Commit

Permalink
Add helper text support for default select list component
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamindehli committed May 2, 2024
1 parent 306b059 commit e449a4d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/Template/DefaultSelectList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function DefaultSelectList({
const labelWithFallback = label || capitalizeFirstLetter(name);
const idWithFallback = id || name;
const helperTextId = `${idWithFallback}-helper-text`;
const hasHelperText = !!helperText?.length;

return (
<FormControl margin="dense" fullWidth variant="outlined">
Expand All @@ -52,7 +53,7 @@ export function DefaultSelectList({
label={labelWithFallback}
input={<OutlinedInput label="Glide mode" />}
endAdornment={
helperText?.length && (
hasHelperText && (
<InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
Expand All @@ -65,6 +66,11 @@ export function DefaultSelectList({
</InputAdornment>
)
}
sx={{
"& .MuiSelect-icon": hasHelperText && {
marginRight: 5
}
}}
>
{options.map((option) => (
<MenuItem
Expand All @@ -81,7 +87,7 @@ export function DefaultSelectList({
</MenuItem>
))}
</Select>
{helperText?.length && (
{hasHelperText && (
<Collapse in={showHelperText}>
<FormHelperText id={helperTextId}>{helperText}</FormHelperText>
</Collapse>
Expand Down

0 comments on commit e449a4d

Please sign in to comment.