From bb48617101fc8824b76328d03972f93ca96d583e Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Wed, 27 Sep 2023 17:19:05 +1000 Subject: [PATCH] fix(ui): memoize canvas context menu callback --- .../web/src/features/canvas/components/IAICanvas.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/invokeai/frontend/web/src/features/canvas/components/IAICanvas.tsx b/invokeai/frontend/web/src/features/canvas/components/IAICanvas.tsx index 9de50e686c..360d764a6e 100644 --- a/invokeai/frontend/web/src/features/canvas/components/IAICanvas.tsx +++ b/invokeai/frontend/web/src/features/canvas/components/IAICanvas.tsx @@ -139,6 +139,11 @@ const IAICanvas = () => { const { handleDragStart, handleDragMove, handleDragEnd } = useCanvasDragMove(); + const handleContextMenu = useCallback( + (e: KonvaEventObject) => e.evt.preventDefault(), + [] + ); + useEffect(() => { if (!containerRef.current) { return; @@ -205,9 +210,7 @@ const IAICanvas = () => { onDragStart={handleDragStart} onDragMove={handleDragMove} onDragEnd={handleDragEnd} - onContextMenu={(e: KonvaEventObject) => - e.evt.preventDefault() - } + onContextMenu={handleContextMenu} onWheel={handleWheel} draggable={(tool === 'move' || isStaging) && !isModifyingBoundingBox} >