diff --git a/apps/client/src/__tests__/cursor.test.tsx b/apps/client/src/__tests__/cursor.test.tsx index a954d33..1265802 100644 --- a/apps/client/src/__tests__/cursor.test.tsx +++ b/apps/client/src/__tests__/cursor.test.tsx @@ -4,7 +4,7 @@ import { ARROW_TRANSFORMER } from '@/constants/shape'; import { stateGenerator } from '@/test/data-generators'; import { findCanvas, renderWithProviders } from '@/test/test-utils'; import { createNode } from '@/utils/node'; -import { screen, waitFor } from '@testing-library/react'; +import { act, screen, waitFor } from '@testing-library/react'; import Konva from 'konva'; import type { NodeType } from 'shared'; @@ -143,12 +143,16 @@ describe('cursor', () => { const { container } = await findCanvas(); // fire dragStart event - Konva.stages[0].fire('dragstart'); + await act(async () => { + Konva.stages[0].fire('dragstart'); + }); expect(container.style.cursor).toBe('grabbing'); // fire dragEnd event - Konva.stages[0].fire('dragend'); + await act(async () => { + Konva.stages[0].fire('dragend'); + }); expect(container.style.cursor).toBe('grab'); }); @@ -163,12 +167,16 @@ describe('cursor', () => { const { container } = await findCanvas(); // fire dragStart event - Konva.stages[0].fire('dragstart'); + await act(async () => { + Konva.stages[0].fire('dragstart'); + }); expect(container.style.cursor).toBe('all-scroll'); // fire dragEnd event - Konva.stages[0].fire('dragend'); + await act(async () => { + Konva.stages[0].fire('dragend'); + }); expect(container.style.cursor).toBe(''); }); diff --git a/apps/client/src/components/Canvas/Transformer/NodesTransformer.tsx b/apps/client/src/components/Canvas/Transformer/NodesTransformer.tsx index a119e18..a6d3f3d 100644 --- a/apps/client/src/components/Canvas/Transformer/NodesTransformer.tsx +++ b/apps/client/src/components/Canvas/Transformer/NodesTransformer.tsx @@ -56,11 +56,13 @@ const NodesTransformer = ({ }, [selectedNodes, onlySingleNode]); useEffect(() => { - if (!transformerRef.current) { + const transformer = transformerRef.current; + const layer = transformer?.getLayer(); + + if (!transformer || !layer) { return; } - const layer = transformerRef.current.getLayer() as Konva.Layer; const nodeIds = new Set(selectedNodes.map(({ nodeProps }) => nodeProps.id)); const nodes = layer.find((node: Konva.Node) => nodeIds.has(node.id()));