Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not call HOC component each render #2780

Merged
merged 3 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- A couple of css-related issues (top bar disappear, wrong arrow position on collapse elements) (<https://github.com/openvinotoolkit/cvat/pull/2736>)
- Issue with point region doesn't work in Firefox (<https://github.com/openvinotoolkit/cvat/pull/2727>)
- Fixed cuboid perpective change (<https://github.com/openvinotoolkit/cvat/pull/2733>)
- Annotation page popups (ai tools, drawing) reset state after detecting, tracking, drawing (<https://github.com/openvinotoolkit/cvat/pull/2780>)

### Security

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.14.0",
"version": "1.14.1",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -19,10 +19,9 @@ interface Props {
isDrawing: boolean;
}

const CustomPopover = withVisibilityHandling(Popover, 'draw-cuboid');
function DrawPolygonControl(props: Props): JSX.Element {
const { canvasInstance, isDrawing } = props;
const CustomPopover = withVisibilityHandling(Popover, 'draw-cuboid');

const dynamcPopoverPros = isDrawing ?
{
overlayStyle: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -18,10 +18,9 @@ interface Props {
isDrawing: boolean;
}

const CustomPopover = withVisibilityHandling(Popover, 'draw-points');
function DrawPointsControl(props: Props): JSX.Element {
const { canvasInstance, isDrawing } = props;
const CustomPopover = withVisibilityHandling(Popover, 'draw-points');

const dynamcPopoverPros = isDrawing ?
{
overlayStyle: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -18,10 +18,9 @@ interface Props {
isDrawing: boolean;
}

const CustomPopover = withVisibilityHandling(Popover, 'draw-polygon');
function DrawPolygonControl(props: Props): JSX.Element {
const { canvasInstance, isDrawing } = props;
const CustomPopover = withVisibilityHandling(Popover, 'draw-polygon');

const dynamcPopoverPros = isDrawing ?
{
overlayStyle: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -18,10 +18,9 @@ interface Props {
isDrawing: boolean;
}

const CustomPopover = withVisibilityHandling(Popover, 'draw-polyline');
function DrawPolylineControl(props: Props): JSX.Element {
const { canvasInstance, isDrawing } = props;
const CustomPopover = withVisibilityHandling(Popover, 'draw-polyline');

const dynamcPopoverPros = isDrawing ?
{
overlayStyle: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -18,10 +18,9 @@ interface Props {
isDrawing: boolean;
}

const CustomPopover = withVisibilityHandling(Popover, 'draw-rectangle');
function DrawRectangleControl(props: Props): JSX.Element {
const { canvasInstance, isDrawing } = props;
const CustomPopover = withVisibilityHandling(Popover, 'draw-rectangle');

const dynamcPopoverPros = isDrawing ?
{
overlayStyle: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
createAnnotationsAsync,
} from 'actions/annotation-actions';
import LabelSelector from 'components/label-selector/label-selector';
import withVisibilityHandling from './handle-popover-visibility';

interface Props {
labels: any[];
Expand All @@ -55,6 +56,7 @@ interface State {
}

const core = getCore();
const CustomPopover = withVisibilityHandling(Popover, 'opencv-control');

function mapStateToProps(state: CombinedState): Props {
const {
Expand All @@ -73,7 +75,7 @@ function mapStateToProps(state: CombinedState): Props {

return {
isActivated: activeControl === ActiveControl.OPENCV_TOOLS,
canvasInstance,
canvasInstance: canvasInstance as Canvas,
jobInstance,
curZOrder,
labels,
Expand Down Expand Up @@ -402,14 +404,14 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
};

return (
<Popover
<CustomPopover
{...dynamcPopoverPros}
placement='right'
overlayClassName='cvat-opencv-control-popover'
content={this.renderContent()}
>
<Icon {...dynamicIconProps} component={OpenCVIcon} />
</Popover>
</CustomPopover>
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -18,9 +18,9 @@ interface Props {
rotateFrame(rotation: Rotation): void;
}

const CustomPopover = withVisibilityHandling(Popover, 'rotate-canvas');
function RotateControl(props: Props): JSX.Element {
const { anticlockwiseShortcut, clockwiseShortcut, rotateFrame } = props;
const CustomPopover = withVisibilityHandling(Popover, 'rotate-canvas');

return (
<CustomPopover
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -17,10 +17,9 @@ interface Props {
isDrawing: boolean;
}

const CustomPopover = withVisibilityHandling(Popover, 'setup-tag');
function SetupTagControl(props: Props): JSX.Element {
const { isDrawing } = props;
const CustomPopover = withVisibilityHandling(Popover, 'setup-tag');

const dynamcPopoverPros = isDrawing ?
{
overlayStyle: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -56,6 +56,7 @@ interface DispatchToProps {
}

const core = getCore();
const CustomPopover = withVisibilityHandling(Popover, 'tools-control');

function mapStateToProps(state: CombinedState): StateToProps {
const { annotation } = state;
Expand All @@ -73,7 +74,7 @@ function mapStateToProps(state: CombinedState): StateToProps {
activeLabelID: annotation.drawing.activeLabelID,
labels: annotation.job.labels,
states: annotation.annotations.states,
canvasInstance,
canvasInstance: canvasInstance as Canvas,
jobInstance,
frame,
curZOrder: annotation.annotations.zLayer.cur,
Expand Down Expand Up @@ -303,11 +304,7 @@ export class ToolsControlComponent extends React.PureComponent<Props, State> {

private onTracking = async (e: Event): Promise<void> => {
const {
isActivated,
jobInstance,
frame,
curZOrder,
fetchAnnotations,
isActivated, jobInstance, frame, curZOrder, fetchAnnotations,
} = this.props;

if (!isActivated) {
Expand Down Expand Up @@ -520,8 +517,8 @@ export class ToolsControlComponent extends React.PureComponent<Props, State> {
min={1}
precision={0}
max={jobInstance.stopFrame - frame}
onChange={(value: number | undefined | string): void => {
if (typeof value !== 'undefined') {
onChange={(value: number | undefined | string | null): void => {
if (typeof value !== 'undefined' && value !== null) {
this.setState({
trackingFrames: +value,
});
Expand Down Expand Up @@ -659,19 +656,20 @@ export class ToolsControlComponent extends React.PureComponent<Props, State> {
try {
this.setState({ mode: 'detection', fetching: true });
const result = await core.lambda.call(task, model, { ...body, frame });
const states = result.map((data: any): any => (
new core.classes.ObjectState({
shapeType: data.type,
label: task.labels.filter((label: any): boolean => label.name === data.label)[0],
points: data.points,
objectType: ObjectType.SHAPE,
frame,
occluded: false,
source: 'auto',
attributes: {},
zOrder: curZOrder,
})
));
const states = result.map(
(data: any): any =>
new core.classes.ObjectState({
shapeType: data.type,
label: task.labels.filter((label: any): boolean => label.name === data.label)[0],
points: data.points,
objectType: ObjectType.SHAPE,
frame,
occluded: false,
source: 'auto',
attributes: {},
zOrder: curZOrder,
}),
);

await jobInstance.annotations.put(states);
fetchAnnotations();
Expand Down Expand Up @@ -722,7 +720,6 @@ export class ToolsControlComponent extends React.PureComponent<Props, State> {
const { fetching, trackingProgress } = this.state;

if (![...interactors, ...detectors, ...trackers].length) return null;
const CustomPopover = withVisibilityHandling(Popover, 'tools-control');

const dynamcPopoverPros = isActivated ?
{
Expand Down