Skip to content

Commit

Permalink
feat: add clear button
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Murray <hellomikemurray@gmail.com>
  • Loading branch information
mikemurray committed Oct 2, 2019
1 parent 232af57 commit ee51e0c
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions package/src/components/DataTableFilter/DataTableFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const DataTableFilter = React.forwardRef(function DataTableFilter(props, ref) {
control={<Checkbox />}
label={label}
disabled={isDisabled}
checked={Array.isArray(value) && value.includes(optionValue)}
/>
</ListItem>
);
Expand All @@ -117,9 +118,15 @@ const DataTableFilter = React.forwardRef(function DataTableFilter(props, ref) {
menuItems = (
<RadioGroup
onChange={(event) => onSelect(event.target.value)}
defaultValue={value}
value={value || ""}
aria-label={title}
>
<FormControlLabel
style={{ display: "none" }}
key="noneSelected"
control={<Radio />}
value=""
/>
{options.map((option, index) => {
const {
label,
Expand Down Expand Up @@ -151,9 +158,14 @@ const DataTableFilter = React.forwardRef(function DataTableFilter(props, ref) {
<Typography>{title}</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails className={classes.expansionPanelDetails}>
<List>
{menuItems}
</List>
<Box>
<List>
{menuItems}
</List>
<Button onClick={() => onSelect(null)}>
Clear all
</Button>
</Box>
</ExpansionPanelDetails>
</ExpansionPanel>
);
Expand Down Expand Up @@ -189,6 +201,11 @@ const DataTableFilter = React.forwardRef(function DataTableFilter(props, ref) {
</Box>
</MenuItem>
{menuItems}
<ListItem key="clear-button">
<Button onClick={() => onSelect(null)}>
Clear
</Button>
</ListItem>
</Menu>
</Fragment>
);
Expand Down

0 comments on commit ee51e0c

Please sign in to comment.