Skip to content

Commit 42160e0

Browse files
committed
fix region tag update issues
1 parent 9076a77 commit 42160e0

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

src/DebugSidebarBox/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export const DebugSidebarBox = ({ state, lastAction }: any) => {
77
const image = (state.images || []).find(
88
(img) => img.src === state.selectedImage
99
)
10-
const region = image ? (image.regions || []).find((r) => r.highlighted) : null
10+
const region = image
11+
? (image.regions || []).filter((r) => r.highlighted)
12+
: null
1113

1214
return (
1315
<SidebarBoxContainer title="Debug" icon={<span />} expandedByDefault>

src/ImageCanvas/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,11 @@ export const ImageCanvas = ({
264264
bottomRight: mat.clone().inverse().applyToPoint(iw, ih),
265265
}
266266

267-
const highlightedRegion = useMemo(() => regions.find((r) => r.highlighted), [
268-
regions,
269-
])
267+
const highlightedRegion = useMemo(() => {
268+
const highlightedRegions = regions.filter((r) => r.highlighted)
269+
if (highlightedRegions.length !== 1) return null
270+
return highlightedRegions[0]
271+
}, [regions])
270272

271273
return (
272274
<div

src/ImageMask/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const ImageMask = ({
1313
imagePosition,
1414
zIndex = 1,
1515
hide = false,
16-
autoSegmentationOptions = {},
16+
autoSegmentationOptions = { type: "simple" },
1717
}) => {
1818
if (!window.mmgc) window.mmgc = MMGC_INIT()
1919
const mmgc = window.mmgc

src/RegionLabel/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,5 @@ export default memo(
165165
RegionLabel,
166166
(prevProps, nextProps) =>
167167
prevProps.editing === nextProps.editing &&
168-
prevProps.region.x === nextProps.region.x &&
169-
prevProps.region.y === nextProps.region.y &&
170-
prevProps.region.tags === nextProps.region.tags &&
171-
prevProps.region.cls === nextProps.region.cls &&
172-
prevProps.region.color === nextProps.region.color &&
173-
prevProps.region.highlighted === nextProps.region.highlighted
168+
prevProps.region === nextProps.region
174169
)

0 commit comments

Comments
 (0)