From 313f5e2ef4cbcd7fe564f590d5d642ce2bf817c1 Mon Sep 17 00:00:00 2001 From: Martin Turoci Date: Tue, 27 Sep 2022 12:37:39 +0200 Subject: [PATCH] chore: Refactor. #1597 --- ui/src/image_annotator.tsx | 1 - ui/src/image_annotator_rect.ts | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ui/src/image_annotator.tsx b/ui/src/image_annotator.tsx index 0b28d68d22..22a08dafb4 100644 --- a/ui/src/image_annotator.tsx +++ b/ui/src/image_annotator.tsx @@ -212,7 +212,6 @@ export const XImageAnnotator = ({ model }: { model: ImageAnnotator }) => { switch (activeShape) { case 'rect': { - // TODO: Fix rect selection. rectRef.current?.onClick(e, cursor_x, cursor_y, setDrawnShapes, activeTag, start) break } diff --git a/ui/src/image_annotator_rect.ts b/ui/src/image_annotator_rect.ts index 6c50426f4a..86f895ca2e 100644 --- a/ui/src/image_annotator_rect.ts +++ b/ui/src/image_annotator_rect.ts @@ -53,10 +53,9 @@ export class RectAnnotator { } onClick = (e: React.MouseEvent, cursor_x: U, cursor_y: U, setDrawnShapes: (value: React.SetStateAction) => void, tag: S, start?: Position) => { - let newRect = null if (start && !this.resizedCorner) { const rect = this.createRect(start.x, cursor_x, start.y, cursor_y) - if (rect) newRect = ({ shape: { rect: rect }, tag }) + if (rect) setDrawnShapes(drawnShapes => [{ shape: { rect }, tag }, ...drawnShapes]) } if (!this.resizedCorner && !start?.dragging && e.type !== 'mouseleave') { @@ -68,8 +67,6 @@ export class RectAnnotator { this.resizedCorner = undefined this.movedRect = undefined - - return newRect } onMouseDown(cursor_x: U, cursor_y: U, rect: ImageAnnotatorRect) {