Closed SerinaJingyiLu closed 4 years ago
I think it has no problem as I
e.stopPropagation();
?
Yeah, it works well when select an edge or a node. However, for the code below:
useEventListener('mousedown', useCallback(() => {
dispatch({ type: 'unselectAllEdges' });
}, [dispatch]));
or
useEventListener('mousedown', useCallback(() => {
dispatch({ type: 'unselectAllNodes' });
}, [dispatch]));
If you do not set the scope for 'unselectAllEdges' or 'unselectAllNodes' event, these events will be triggered anywhere your mouse is down, which means when you want to click the 'delete' button, it will first trigger the 'unselectAllEdges' or 'unselectAllNodes' event, and no selected edge or node can be captured.
I have already added prettier to unify the format. You can run the script 'npm run prettier' to format it or the code will be automatically formatted when you run 'git commit'. The config for prettier can be changed. Right now, I am using semi with single quote and trailing comma.
I think it has no problem as I
e.stopPropagation();
?Yeah, it works well when select an edge or a node. However, for the code below:
useEventListener('mousedown', useCallback(() => { dispatch({ type: 'unselectAllEdges' }); }, [dispatch]));
or
useEventListener('mousedown', useCallback(() => { dispatch({ type: 'unselectAllNodes' }); }, [dispatch]));
If you do not set the scope for 'unselectAllEdges' or 'unselectAllNodes' event, these events will be triggered anywhere your mouse is down, which means when you want to click the 'delete' button, it will first trigger the 'unselectAllEdges' or 'unselectAllNodes' event, and no selected edge or node can be captured.
Oh, yes. Maybe the event listener should be added to Canvas instead of Window in the future. Anyway, let's use your fix for now.
I have already added prettier to unify the format. You can run the script 'npm run prettier' to format it or the code will be automatically formatted when you run 'git commit'. The config for prettier can be changed. Right now, I am using semi with single quote and trailing comma.
Great!
Besides, I still have some concerns on edge selection. why do we need to 'unselectedAllNodes' when an edge is selected?