Skip to content

Commit

Permalink
fix: πŸ› Fixs dropdown font size and renders empty label - -
Browse files Browse the repository at this point in the history
Fixes*

βœ… Closes: #30
  • Loading branch information
Sean Groff committed Dec 22, 2020
1 parent 40d1e42 commit 2308d55
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/components/SQForm/SQFormMultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Checkbox from '@material-ui/core/Checkbox';
import ListItemText from '@material-ui/core/ListItemText';
import Tooltip from '@material-ui/core/Tooltip';
import {useSQFormContext} from '../../../src';
import {EMPTY_LABEL} from '../../utils/constants';
import {useForm} from './useForm';

/**
Expand Down Expand Up @@ -109,12 +110,14 @@ function SQFormMultiSelect({
* e.g., if value is an "ID"
*/
const getRenderValue = selected => {
const selectedChildren = children
if (!selected.length) {
return EMPTY_LABEL;
}

return children
?.filter(child => selected.includes(child.value))
?.map(child => child.label)
?.join(', ');

return selectedChildren;
};

return (
Expand All @@ -129,6 +132,7 @@ function SQFormMultiSelect({
>
<Select
multiple
displayEmpty
input={<Input disabled={isDisabled} name={name} />}
value={field.value}
onBlur={handleBlur}
Expand All @@ -145,14 +149,20 @@ function SQFormMultiSelect({
value={children.length === field.value.length ? 'NONE' : 'ALL'}
>
<Checkbox checked={children.length === field.value.length} />
<ListItemText primary="Select All" />
<ListItemText
primary="Select All"
primaryTypographyProps={{variant: 'body2'}}
/>
</MenuItem>
)}
{children.map(option => {
return (
<MenuItem key={option.value} value={option.value}>
<Checkbox checked={field.value.includes(option.value)} />
<ListItemText primary={option.label} />
<ListItemText
primary={option.label}
primaryTypographyProps={{variant: 'body2'}}
/>
</MenuItem>
);
})}
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const EMPTY_LABEL = '- -';

0 comments on commit 2308d55

Please sign in to comment.