Skip to content

Commit

Permalink
feat(selection): clear user selection when mouse leaves the pane
Browse files Browse the repository at this point in the history
  • Loading branch information
chrtze committed Oct 6, 2020
1 parent 42202ba commit 0045058
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/UserSelection/index.tsx
Expand Up @@ -51,6 +51,7 @@ export default memo(({ selectionKeyPressed }: UserSelectionProps) => {
const setUserSelection = useStoreActions((actions) => actions.setUserSelection);
const updateUserSelection = useStoreActions((actions) => actions.updateUserSelection);
const unsetUserSelection = useStoreActions((actions) => actions.unsetUserSelection);
const unsetNodesSelection = useStoreActions((actions) => actions.unsetNodesSelection);
const renderUserSelectionPane = selectionActive || selectionKeyPressed;

if (!elementsSelectable || !renderUserSelectionPane) {
Expand Down Expand Up @@ -81,12 +82,18 @@ export default memo(({ selectionKeyPressed }: UserSelectionProps) => {

const onMouseUp = () => unsetUserSelection();

const onMouseLeave = () => {
unsetUserSelection();
unsetNodesSelection();
};

return (
<div
className="react-flow__selectionpane"
onMouseDown={onMouseDown}
onMouseMove={onMouseMove}
onMouseUp={onMouseUp}
onMouseLeave={onMouseLeave}
>
<SelectionRect />
</div>
Expand Down

0 comments on commit 0045058

Please sign in to comment.