Skip to content

Commit e5bd5e4

Browse files
authored
fix(canvas): add handler for focus loss for hotkey operations (#2701)
1 parent e9aede0 commit e5bd5e4

File tree

1 file changed

+15
-0
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]

1 file changed

+15
-0
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,11 +1947,26 @@ const WorkflowContent = React.memo(() => {
19471947
const handleKeyUp = (e: KeyboardEvent) => {
19481948
if (e.key === 'Shift') setIsShiftPressed(false)
19491949
}
1950+
const handleFocusLoss = () => {
1951+
setIsShiftPressed(false)
1952+
setIsSelectionDragActive(false)
1953+
}
1954+
const handleVisibilityChange = () => {
1955+
if (document.hidden) {
1956+
handleFocusLoss()
1957+
}
1958+
}
1959+
19501960
window.addEventListener('keydown', handleKeyDown)
19511961
window.addEventListener('keyup', handleKeyUp)
1962+
window.addEventListener('blur', handleFocusLoss)
1963+
document.addEventListener('visibilitychange', handleVisibilityChange)
1964+
19521965
return () => {
19531966
window.removeEventListener('keydown', handleKeyDown)
19541967
window.removeEventListener('keyup', handleKeyUp)
1968+
window.removeEventListener('blur', handleFocusLoss)
1969+
document.removeEventListener('visibilitychange', handleVisibilityChange)
19551970
}
19561971
}, [])
19571972

0 commit comments

Comments
 (0)