Skip to content

Commit

Permalink
Fixed: "TypeError: Cannot read property 'clientX' of undefined" (#3308)
Browse files Browse the repository at this point in the history
* Fixed cuboid redraw

* Updated version & changelog

* Fixed duplicated cuboid

* Updated changelog

* Do not skip test for cuboid

* Removed comment

* Fixed one more case
  • Loading branch information
Boris Sekachev committed Jun 16, 2021
1 parent 85e57c1 commit 957bc29
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix CLI create an infinite loop if git repository responds with failure (<https://github.com/openvinotoolkit/cvat/pull/3267>)
- Bug with sidebar & fullscreen (<https://github.com/openvinotoolkit/cvat/pull/3289>)
- 504 Gateway Time-out on `data/meta` requests (<https://github.com/openvinotoolkit/cvat/pull/3269>)
- TypeError: Cannot read property 'clientX' of undefined when draw cuboids with hotkeys (<https://github.com/openvinotoolkit/cvat/pull/3308>)
- Duplication of the cuboids when redraw them (<https://github.com/openvinotoolkit/cvat/pull/3308>)
- Some code issues in Deep Extreme Cut handler code (<https://github.com/openvinotoolkit/cvat/pull/3325>)

### Security
Expand Down
8 changes: 5 additions & 3 deletions cvat-canvas/src/typescript/drawHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ export class DrawHandlerImpl implements DrawHandler {
// We check if it is activated with remember function
if (this.drawInstance.remember('_paintHandler')) {
if (
this.drawData.shapeType !== 'rectangle'
&& this.drawData.cuboidDrawingMethod !== CuboidDrawingMethod.CLASSIC
['polygon', 'polyline', 'points'].includes(this.drawData.shapeType)
|| (this.drawData.shapeType === 'cuboid'
&& this.drawData.cuboidDrawingMethod === CuboidDrawingMethod.CORNER_POINTS)
) {
// Check for unsaved drawn shapes
this.drawInstance.draw('done');
Expand Down Expand Up @@ -574,7 +575,7 @@ export class DrawHandlerImpl implements DrawHandler {
.on('drawstop', (e: Event): void => {
const bbox = (e.target as SVGRectElement).getBBox();
const [xtl, ytl, xbr, ybr] = this.getFinalRectCoordinates(bbox);
const { shapeType } = this.drawData;
const { shapeType, redraw: clientID } = this.drawData;
this.release();

if (this.canceled) return;
Expand All @@ -584,6 +585,7 @@ export class DrawHandlerImpl implements DrawHandler {
{
shapeType,
points: cuboidFrom4Points([xtl, ybr, xbr, ybr, xbr, ytl, xbr + d.x, ytl - d.y]),
clientID,
},
Date.now() - this.startTimestamp,
);
Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-ui",
"version": "1.20.3",
"version": "1.20.4",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion cvat-ui/src/actions/annotation-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ActionCreator, AnyAction, Dispatch, Store,
} from 'redux';
import { ThunkAction } from 'utils/redux';
import { RectDrawingMethod, Canvas } from 'cvat-canvas-wrapper';
import { RectDrawingMethod, CuboidDrawingMethod, Canvas } from 'cvat-canvas-wrapper';
import getCore from 'cvat-core-wrapper';
import logger, { LogType } from 'cvat-logger';
import { getCVATStore } from 'cvat-store';
Expand Down Expand Up @@ -1134,6 +1134,7 @@ export function rememberObject(createParams: {
activeShapeType?: ShapeType;
activeNumOfPoints?: number;
activeRectDrawingMethod?: RectDrawingMethod;
activeCuboidDrawingMethod?: CuboidDrawingMethod;
}): AnyAction {
return {
type: AnnotationActionTypes.REMEMBER_CREATED_OBJECT,
Expand Down Expand Up @@ -1480,6 +1481,7 @@ export function repeatDrawShapeAsync(): ThunkAction {
activeShapeType,
activeNumOfPoints,
activeRectDrawingMethod,
activeCuboidDrawingMethod,
},
} = getStore().getState().annotation;

Expand Down Expand Up @@ -1534,6 +1536,7 @@ export function repeatDrawShapeAsync(): ThunkAction {
canvasInstance.draw({
enabled: true,
rectDrawingMethod: activeRectDrawingMethod,
cuboidDrawingMethod: activeCuboidDrawingMethod,
numberOfPoints: activeNumOfPoints,
shapeType: activeShapeType,
crosshair: [ShapeType.RECTANGLE, ShapeType.CUBOID].includes(activeShapeType),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface DispatchToProps {
objectType: ObjectType,
points?: number,
rectDrawingMethod?: RectDrawingMethod,
cuboidDrawingMethod?: CuboidDrawingMethod,
): void;
}

Expand All @@ -42,6 +43,7 @@ function mapDispatchToProps(dispatch: any): DispatchToProps {
objectType: ObjectType,
points?: number,
rectDrawingMethod?: RectDrawingMethod,
cuboidDrawingMethod?: CuboidDrawingMethod,
): void {
dispatch(
rememberObject({
Expand All @@ -50,6 +52,7 @@ function mapDispatchToProps(dispatch: any): DispatchToProps {
activeLabelID: labelID,
activeNumOfPoints: points,
activeRectDrawingMethod: rectDrawingMethod,
activeCuboidDrawingMethod: cuboidDrawingMethod,
}),
);
},
Expand Down Expand Up @@ -127,7 +130,7 @@ class DrawShapePopoverContainer extends React.PureComponent<Props, State> {
crosshair: [ShapeType.RECTANGLE, ShapeType.CUBOID].includes(shapeType),
});

onDrawStart(shapeType, selectedLabelID, objectType, numberOfPoints, rectDrawingMethod);
onDrawStart(shapeType, selectedLabelID, objectType, numberOfPoints, rectDrawingMethod, cuboidDrawingMethod);
}

private onChangeRectDrawingMethod = (event: RadioChangeEvent): void => {
Expand Down
3 changes: 2 additions & 1 deletion cvat-ui/src/reducers/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { MutableRefObject } from 'react';
import { Canvas3d } from 'cvat-canvas3d/src/typescript/canvas3d';
import { Canvas, RectDrawingMethod } from 'cvat-canvas-wrapper';
import { Canvas, RectDrawingMethod, CuboidDrawingMethod } from 'cvat-canvas-wrapper';
import { IntelligentScissors } from 'utils/opencv-wrapper/intelligent-scissors';
import { KeyMap } from 'utils/mousetrap-react';

Expand Down Expand Up @@ -452,6 +452,7 @@ export interface AnnotationState {
activeInteractor?: Model | OpenCVTool;
activeShapeType: ShapeType;
activeRectDrawingMethod?: RectDrawingMethod;
activeCuboidDrawingMethod?: CuboidDrawingMethod;
activeNumOfPoints?: number;
activeLabelID: number;
activeObjectType: ObjectType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ context('Redraw feature.', () => {
});
});

it.skip('Draw and redraw a cuboid.', () => {
// Need to fix issue https://github.com/openvinotoolkit/cvat/issues/2873
it('Draw and redraw a cuboid.', () => {
cy.createCuboid(createCuboidShape2Points);
cy.get('.cvat-canvas-container').trigger('mousemove', 300, 400);
cy.get('#cvat_canvas_shape_5').should('have.class', 'cvat_canvas_shape_activated');
Expand Down

0 comments on commit 957bc29

Please sign in to comment.