Skip to content

Commit 601db39

Browse files
committed
Add a reset button in modalities filter
1 parent 1c98f39 commit 601db39

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/components/NodesFilter/ModalitiesFilter.tsx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { Box, FormControlLabel, Checkbox, Typography } from "@mui/material";
1+
import {
2+
Box,
3+
FormControlLabel,
4+
Checkbox,
5+
Typography,
6+
Button,
7+
} from "@mui/material";
28
import { Colors } from "design/theme";
39
import { DATA_TYPE_COLORS } from "modules/universe/NeuroJsonGraph";
410
import React, { useEffect, useState } from "react";
@@ -30,6 +36,12 @@ const ModalitiesFilter: React.FC<ModalitiesFilterProps> = ({
3036
onFilter(updatedModalities);
3137
};
3238

39+
// reset function to clear all selected checkedboxes
40+
const handleReset = () => {
41+
setSelectedModalities([]); // clear the local state
42+
onFilter([]); // notify parent that selection is reset
43+
};
44+
3345
return (
3446
<Box>
3547
{modalitiesList.map((modality) => {
@@ -77,6 +89,7 @@ const ModalitiesFilter: React.FC<ModalitiesFilterProps> = ({
7789
marginBottom: "5px",
7890
fontWeight: "bold",
7991
minWidth: "45px",
92+
textAlign: "center",
8093
}}
8194
>
8295
{modality}
@@ -86,6 +99,24 @@ const ModalitiesFilter: React.FC<ModalitiesFilterProps> = ({
8699
</Box>
87100
);
88101
})}
102+
{/* Reset button */}
103+
<Button
104+
variant="contained"
105+
sx={{
106+
marginTop: "10px",
107+
backgroundColor: Colors.white,
108+
color: Colors.purple,
109+
fontWeight: "bold",
110+
"&:hover": {
111+
backgroundColor: Colors.darkPurple,
112+
color: Colors.green,
113+
boxShadow: `0px 0px 15px ${Colors.darkGreen}`,
114+
},
115+
}}
116+
onClick={handleReset}
117+
>
118+
Clear
119+
</Button>
89120
</Box>
90121
);
91122
};

0 commit comments

Comments
 (0)