Skip to content

Commit c8f8cb5

Browse files
authored
Fix Shift+Click on Canvas Selecting Text in Panels (#1347)
## Description <!-- Please provide a brief description of the changes made in this pull request. Include any relevant context or reasoning for the changes. --> Fixes an issue where if the previous selection or active element was inside the sidebar or context panel a shift + click operation on the canvas would select content in that panel instead of on the canvas. ## Related Issue and Pull requests <!-- Link to any related issues using the format #<issue-number> --> ## Type of Change <!-- Please delete options that are not relevant --> - [x] Bug fix ## Checklist <!-- Please ensure the following are completed before submitting the PR --> - [ ] I have tested this does not break current pipelines / runs functionality - [ ] I have tested the changes on staging ## Screenshots (if applicable) <!-- Include any screenshots that might help explain the changes or provide visual context --> ## Test Instructions <!-- Detail steps and prerequisites for testing the changes in this PR --> HOW TO REPRODUCE THE ORIGINAL BUG go on master branch: 1. click inside the sidebar or context panel 2. shift + drag to select nodes on the canvas 3. text in the panel you click on should be selected bad! HOW TO TEST THAT IT'S FIXED switch to the branch for this PR 1. repeat the steps above 2. text in the panel should no longer get selected - only the nodes you've chosen good! ## Additional Comments <!-- Add any additional context or information that reviewers might need to know regarding this PR -->
1 parent 1731486 commit c8f8cb5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/components/shared/ReactFlow/FlowCanvas/FlowCanvas.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,26 @@ const FlowCanvas = ({
227227
}
228228
}, []);
229229

230+
const handleMouseDown = useCallback((event: MouseEvent) => {
231+
if (event.shiftKey && event.target instanceof HTMLElement) {
232+
const reactFlowWrapper = event.target.closest(".react-flow");
233+
if (reactFlowWrapper) {
234+
event.preventDefault();
235+
}
236+
}
237+
}, []);
238+
230239
useEffect(() => {
231240
document.addEventListener("keydown", handleKeyDown);
232241
document.addEventListener("keyup", handleKeyUp);
242+
document.addEventListener("mousedown", handleMouseDown);
233243

234244
return () => {
235245
document.removeEventListener("keydown", handleKeyDown);
236246
document.removeEventListener("keyup", handleKeyUp);
247+
document.removeEventListener("mousedown", handleMouseDown);
237248
};
238-
}, [handleKeyDown, handleKeyUp]);
249+
}, [handleKeyDown, handleKeyUp, handleMouseDown]);
239250

240251
const [reactFlowInstance, setReactFlowInstance] =
241252
useState<ReactFlowInstance>();

0 commit comments

Comments
 (0)