diff --git a/cvat-ui/src/components/annotation-page/standard-workspace/canvas-wrapper.tsx b/cvat-ui/src/components/annotation-page/standard-workspace/canvas-wrapper.tsx index 76d429f7..75927697 100644 --- a/cvat-ui/src/components/annotation-page/standard-workspace/canvas-wrapper.tsx +++ b/cvat-ui/src/components/annotation-page/standard-workspace/canvas-wrapper.tsx @@ -341,11 +341,10 @@ export default class CanvasWrapperComponent extends React.PureComponent { const { activatedStateID, onUpdateContextMenu, - contextVisible, contextType, } = this.props; - if (!contextVisible && contextType !== ContextMenuType.CANVAS_SHAPE_POINT) { + if (contextType !== ContextMenuType.CANVAS_SHAPE_POINT) { onUpdateContextMenu(activatedStateID !== null, e.clientX, e.clientY, ContextMenuType.CANVAS_SHAPE); } diff --git a/cvat-ui/src/containers/annotation-page/standard-workspace/canvas-point-context-menu.tsx b/cvat-ui/src/containers/annotation-page/standard-workspace/canvas-point-context-menu.tsx index 74d07ff8..59786d8d 100644 --- a/cvat-ui/src/containers/annotation-page/standard-workspace/canvas-point-context-menu.tsx +++ b/cvat-ui/src/containers/annotation-page/standard-workspace/canvas-point-context-menu.tsx @@ -13,7 +13,7 @@ import CanvasPointContextMenuComponent from 'components/annotation-page/standard interface StateToProps { activatedStateID: number | null; - activetedPointID: number | null | undefined; + activatedPointID: number | null | undefined; states: any[]; visible: boolean; top: number; @@ -34,7 +34,7 @@ function mapStateToProps(state: CombinedState): StateToProps { top, left, type, - pointID: activetedPointID, + pointID: activatedPointID, }, }, }, @@ -42,7 +42,7 @@ function mapStateToProps(state: CombinedState): StateToProps { return { activatedStateID, - activetedPointID, + activatedPointID, states, visible, left, @@ -70,6 +70,8 @@ function mapDispatchToProps(dispatch: any): DispatchToProps { type Props = StateToProps & DispatchToProps; interface State { + activatedStateID: number | null | undefined; + activatedPointID: number | null | undefined; latestLeft: number; latestTop: number; left: number; @@ -81,6 +83,8 @@ class CanvasContextMenuContainer extends React.PureComponent { super(props); this.state = { + activatedStateID: null, + activatedPointID: null, latestLeft: 0, latestTop: 0, left: 0, @@ -88,19 +92,25 @@ class CanvasContextMenuContainer extends React.PureComponent { }; } - static getDerivedStateFromProps(props: Props, state: State): State | null { - if (props.left === state.latestLeft - && props.top === state.latestTop) { - return null; + static getDerivedStateFromProps(props: Props, state: State): State { + const newState: State = { ...state }; + + if (props.left !== state.latestLeft + || props.top !== state.latestTop) { + newState.latestLeft = props.left; + newState.latestTop = props.top; + newState.top = props.top; + newState.left = props.left; } - return { - ...state, - latestLeft: props.left, - latestTop: props.top, - top: props.top, - left: props.left, - }; + if (typeof state.activatedStateID !== typeof props.activatedStateID + || typeof state.activatedPointID !== typeof props.activatedPointID) { + newState.activatedStateID = props.activatedStateID; + newState.activatedPointID = props.activatedPointID; + } + + + return newState; } public componentDidUpdate(): void { @@ -130,17 +140,20 @@ class CanvasContextMenuContainer extends React.PureComponent { private deletePoint(): void { const { - activetedPointID, - activatedStateID, states, onUpdateAnnotations, onCloseContextMenu, } = this.props; + const { + activatedStateID, + activatedPointID, + } = this.state; + const [objectState] = states.filter((e) => (e.clientID === activatedStateID)); - if (activetedPointID) { - objectState.points = objectState.points.slice(0, activetedPointID * 2) - .concat(objectState.points.slice(activetedPointID * 2 + 2)); + if (typeof activatedPointID === 'number') { + objectState.points = objectState.points.slice(0, activatedPointID * 2) + .concat(objectState.points.slice(activatedPointID * 2 + 2)); onUpdateAnnotations([objectState]); onCloseContextMenu(); }