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) {