From b418e9efc47ccc111b93fccf8ba2629d2dd5aed8 Mon Sep 17 00:00:00 2001 From: saschamuellercerpro Date: Thu, 1 Aug 2024 11:02:06 +0200 Subject: [PATCH 1/2] done --- src/components/Board/Board.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/Board/Board.tsx b/src/components/Board/Board.tsx index 24fe097..9f22102 100644 --- a/src/components/Board/Board.tsx +++ b/src/components/Board/Board.tsx @@ -19,6 +19,7 @@ export type BoardProps = { }; helper: (id: string, content?: string) => React.ReactNode; onResetZoom?: () => void; + onSelectItem?: (item: fabric.Object) => void; onZoomChange?: (currentZoom: number) => void; onLoadedImage?: ({ width, @@ -49,6 +50,7 @@ const Board = React.forwardRef( items, onResetZoom, onZoomChange, + onSelectItem, onLoadedImage, onItemHover, helper, @@ -560,6 +562,7 @@ const Board = React.forwardRef( if (selected && !isDrawing) { updateObjectHelper(selected); } + onSelectItem && selected && onSelectItem(selected); }; // Some element was selected From daa16d9dbd5ccf504bbfdac514011a14b79acac8 Mon Sep 17 00:00:00 2001 From: saschamuellercerpro Date: Thu, 1 Aug 2024 11:11:53 +0200 Subject: [PATCH 2/2] also on deselect --- src/components/Board/Board.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Board/Board.tsx b/src/components/Board/Board.tsx index 9f22102..f9537df 100644 --- a/src/components/Board/Board.tsx +++ b/src/components/Board/Board.tsx @@ -19,7 +19,7 @@ export type BoardProps = { }; helper: (id: string, content?: string) => React.ReactNode; onResetZoom?: () => void; - onSelectItem?: (item: fabric.Object) => void; + onSelectItem?: (item: fabric.Object | null) => void; onZoomChange?: (currentZoom: number) => void; onLoadedImage?: ({ width, @@ -576,6 +576,7 @@ const Board = React.forwardRef( function (this: fabricTypes.CanvasAnnotationState, _opt) { // const selectedObject = opt.deselected?.[0]; setObjectHelper({ enabled: false, top: 0, left: 0 }); + onSelectItem && onSelectItem(null); }, );