Skip to content

Commit 7076d73

Browse files
committed
#417 stop treeItem click propagation for collapse/expand
1 parent b114602 commit 7076d73

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

webapp/components/general/ControlPanelTreeItem.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from 'react';
22
import { makeStyles } from '@material-ui/core/styles';
3-
import Box from '@material-ui/core/Box';
43
import Grid from '@material-ui/core/Grid';
54
import Typography from '@material-ui/core/Typography';
65
import IconButton from '@material-ui/core/IconButton';
@@ -39,7 +38,7 @@ const ControlPanelTreeItem = (props) => {
3938
const [isHoveredOver, setIsHoveredOver] = React.useState(false);
4039
const [color, setColor] = React.useState('#ff0000');
4140

42-
const handleColorSelection = (color, event, nodeId) => {
41+
const handleColorSelection = (color, nodeId) => {
4342
setColor(color.hex);
4443
};
4544

@@ -66,6 +65,7 @@ const ControlPanelTreeItem = (props) => {
6665
return (
6766
<TreeItem
6867
nodeId={nodeId}
68+
onLabelClick={(e) => { e.stopPropagation(); e.preventDefault(); }}
6969
label={(
7070
<Grid
7171
container
@@ -76,7 +76,7 @@ const ControlPanelTreeItem = (props) => {
7676
flexDirection="row"
7777
justifyContent="space-between"
7878
>
79-
<Grid item xs={4}><Typography onClick={(event) => onNodeSelect(event, nodeId)}>{label}</Typography></Grid>
79+
<Grid item xs={4}><Typography onClick={() => onNodeSelect(nodeId)}>{label}</Typography></Grid>
8080
<Grid item xs={4} justifyContent="center"><Typography>{type}</Typography></Grid>
8181
<Grid item xs={4} justifyContent="flex-end" className={classes.controls}>
8282
{isHoveredOver
@@ -92,7 +92,7 @@ const ControlPanelTreeItem = (props) => {
9292
<ChromePicker
9393
className={classes.colorPicker}
9494
color={color}
95-
onChangeComplete={(e, color) => handleColorSelection(e, color, nodeId)}
95+
onChangeComplete={(color) => handleColorSelection(color, nodeId)}
9696
/>
9797
) : null
9898
}

webapp/components/general/ExperimentControlPanel.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ const useStyles = makeStyles(() => ({
2424
const ExperimentControlPanel = (props) => {
2525
const classes = useStyles();
2626
const [filter, setFilter] = React.useState('');
27-
const onNodeSelect = (event, nodeId) => {
28-
event.preventDefault();
29-
event.stopPropagation();
27+
const onNodeSelect = (nodeId) => {
3028
console.log(`Node with id ${nodeId} clicked`);
3129
};
3230

0 commit comments

Comments
 (0)