Skip to content

Commit

Permalink
fix: Fixes bug where clicking on the canvas did not remove focus from…
Browse files Browse the repository at this point in the history
… other elements
  • Loading branch information
ShrimpCryptid committed Feb 4, 2025
1 parent c30f799 commit 69d6087
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/CanvasWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,17 @@ export default function CanvasWrapper(inputProps: CanvasWrapperProps): ReactElem

const onMouseClick = useCallback(
(event: MouseEvent): void => {
// Note that click events won't fire until the mouse is released. We need to check
// if the mouse was dragged before treating the click as a track selection; otherwise
// the track selection gets changed unexpectedly.
// Note that click events won't fire until the mouse is released. We need
// to check if the mouse was dragged before treating the click as a track
// selection; otherwise the track selection gets changed unexpectedly.
if (!isMouseDragging.current) {
handleTrackSelection(event);
}
// Blur inputs when users interact with the canvas to prevent a bug where
// other inputs remain focused and block arrow key navigation.
if (document.activeElement instanceof HTMLElement) {
document.activeElement.blur();
}
},
[handleTrackSelection]
);
Expand Down

0 comments on commit 69d6087

Please sign in to comment.