@@ -20,7 +20,7 @@ import {
2020 ColorLensIcon ,
2121 TriangleIcon ,
2222} from './NetPyNEIcons' ;
23- import { changeInstanceColor , selectInstances } from '../../redux/actions/general' ;
23+ import { changeInstanceColor } from '../../redux/actions/general' ;
2424
2525const useStyles = makeStyles ( ( theme ) => ( {
2626 treeItem : {
@@ -136,6 +136,8 @@ const ControlPanelTreeItem = (props) => {
136136 } ) ;
137137 dispatch ( changeInstanceColor ( newInstances ) ) ;
138138 setColor ( _color . rgb ) ;
139+ event . stopPropagation ( ) ;
140+ event . preventDefault ( ) ;
139141 } ;
140142
141143 const getRandomColor = ( ) => ( {
@@ -146,6 +148,8 @@ const ControlPanelTreeItem = (props) => {
146148 } ) ;
147149
148150 const generateRandomColor = ( event , nodeId ) => {
151+ event . stopPropagation ( ) ;
152+ event . preventDefault ( ) ;
149153 const children = window . Instances . getInstance ( nodeId ) . getChildren ( ) . map ( ( instance ) => instance . getInstancePath ( ) ) ;
150154 // const newInstances = instances.filter((instance) => !(instance.instancePath.startsWith(nodeId)));
151155 const newInstances = instances . filter ( ( instance ) => {
@@ -174,6 +178,8 @@ const ControlPanelTreeItem = (props) => {
174178 } ;
175179
176180 const changeVisibility = ( event , nodeId ) => {
181+ event . stopPropagation ( ) ;
182+ event . preventDefault ( ) ;
177183 const copiedInstances = instances . slice ( ) ;
178184 let oldIndex = null ;
179185 let oldInstance = copiedInstances . find ( ( pInstance , index ) => {
@@ -223,7 +229,6 @@ const ControlPanelTreeItem = (props) => {
223229 < TreeItem
224230 className = { `${ classes . treeItem } ${ children . length == 0 ? classes . leafTreeItem : '' } ` }
225231 nodeId = { nodeId }
226- onLabelClick = { ( e ) => { e . stopPropagation ( ) ; e . preventDefault ( ) ; } }
227232 label = { (
228233 < Grid
229234 container
@@ -235,7 +240,12 @@ const ControlPanelTreeItem = (props) => {
235240 >
236241
237242 < Grid item xs = { 4 } >
238- < Typography onClick = { ( ) => onNodeSelect ( nodeId ) } >
243+ < Typography onClick = { ( event ) => {
244+ onNodeSelect ( nodeId ) ;
245+ event . stopPropagation ( ) ;
246+ event . preventDefault ( ) ;
247+ } }
248+ >
239249 { label }
240250 </ Typography >
241251 </ Grid >
@@ -247,7 +257,12 @@ const ControlPanelTreeItem = (props) => {
247257 < IconButton onClick = { ( event ) => changeVisibility ( event , nodeId ) } >
248258 { visibility ? < Visibility style = { { marginRight : '0.5rem' } } /> : < VisibilityOff style = { { marginRight : '0.5rem' } } /> }
249259 </ IconButton >
250- < IconButton onClick = { ( ) => setShowColorPicker ( true ) } >
260+ < IconButton onClick = { ( event ) => {
261+ event . stopPropagation ( ) ;
262+ event . preventDefault ( ) ;
263+ setShowColorPicker ( true ) ;
264+ } }
265+ >
251266 < ColorLensIcon className = { showColorPicker ? classes . activeColorPicker : '' } />
252267 </ IconButton >
253268 < IconButton disabled = { disableRandom } onClick = { ( event ) => generateRandomColor ( event , nodeId ) } >
@@ -264,7 +279,9 @@ const ControlPanelTreeItem = (props) => {
264279 < ChromePicker
265280 className = { classes . colorPicker }
266281 color = { color }
267- onChangeComplete = { ( color , event ) => handleColorSelection ( color , event , nodeId ) }
282+ onChangeComplete = { ( color , event ) => {
283+ handleColorSelection ( color , event , nodeId ) ;
284+ } }
268285 />
269286 </ Box >
270287 ) : null
0 commit comments