Skip to content

Commit

Permalink
Fixed exception: State cannot be updated during editing, need to fini…
Browse files Browse the repository at this point in the history
…sh current editing first (#8019)
  • Loading branch information
bsekachev committed Jun 13, 2024
1 parent de95605 commit 05e7a6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelog.d/20240612_162647_boris_fixed_issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Fixed

- Exception: State cannot be updated during editing, need to finish current editing first
(<https://github.com/cvat-ai/cvat/pull/8019>)
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function BrushTools(): React.ReactPortal | null {

const updateEditableState = (e: Event): void => {
const evt = e as CustomEvent;
if (evt.type === 'canvas.editstart' && evt.detail.state) {
if (evt.type === 'canvas.editstart' && evt.detail?.state?.shapeType === ShapeType.MASK) {
setEditableState(evt.detail.state);
} else if (editableState) {
setEditableState(null);
Expand All @@ -179,7 +179,7 @@ function BrushTools(): React.ReactPortal | null {
canvasInstance.html().addEventListener('canvas.drawstart', showToolset);
canvasInstance.html().addEventListener('canvas.editstart', showToolset);
canvasInstance.html().addEventListener('canvas.editstart', updateEditableState);
canvasInstance.html().addEventListener('canvas.editdone', updateEditableState);
canvasInstance.html().addEventListener('canvas.edited', updateEditableState);
}

return () => {
Expand All @@ -191,7 +191,7 @@ function BrushTools(): React.ReactPortal | null {
canvasInstance.html().removeEventListener('canvas.drawstart', showToolset);
canvasInstance.html().removeEventListener('canvas.editstart', showToolset);
canvasInstance.html().removeEventListener('canvas.editstart', updateEditableState);
canvasInstance.html().removeEventListener('canvas.editdone', updateEditableState);
canvasInstance.html().removeEventListener('canvas.edited', updateEditableState);
}
};
}, [visible, editableState, currentTool]);
Expand Down

0 comments on commit 05e7a6a

Please sign in to comment.