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

Fixed: cannot read property 'label' of undefined #2311

Merged
merged 4 commits into from
Oct 13, 2020
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 @@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- A problem in exporting of tracks, where tracks could be truncated (<https://github.com/openvinotoolkit/cvat/issues/2129>)
- Fixed CVAT startup process if the user has `umask 077` in .bashrc file (<https://github.com/openvinotoolkit/cvat/pull/2293>)
- Exception: Cannot read property "each" of undefined after drawing a single point (<https://github.com/openvinotoolkit/cvat/pull/2307>)
- Cannot read property 'label' of undefined (Fixed?) (<https://github.com/openvinotoolkit/cvat/pull/2311>)

### 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.9.12",
"version": "1.9.13",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ import ObjectItemContainer from 'containers/annotation-page/standard-workspace/o

interface Props {
activatedStateID: number | null;
objectStates: any[];
visible: boolean;
left: number;
top: number;
}

export default function CanvasContextMenu(props: Props): JSX.Element | null {
const {
activatedStateID,
visible,
left,
top,
} = props;
const { activatedStateID, objectStates, visible, left, top } = props;

if (!visible || activatedStateID === null) {
return null;
Expand All @@ -31,6 +27,7 @@ export default function CanvasContextMenu(props: Props): JSX.Element | null {
<ObjectItemContainer
key={activatedStateID}
clientID={activatedStateID}
objectStates={objectStates}
initialCollapsed
/>
</div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface Props {
statesCollapsedAll: boolean;
statesOrdering: StatesOrdering;
sortedStatesID: number[];
objectStates: any[];
switchLockAllShortcut: string;
switchHiddenAllShortcut: string;
changeStatesOrdering(value: StatesOrdering): void;
Expand All @@ -34,6 +35,7 @@ function ObjectListComponent(props: Props): JSX.Element {
statesCollapsedAll,
statesOrdering,
sortedStatesID,
objectStates,
switchLockAllShortcut,
switchHiddenAllShortcut,
changeStatesOrdering,
Expand Down Expand Up @@ -63,13 +65,16 @@ function ObjectListComponent(props: Props): JSX.Element {
showAllStates={showAllStates}
/>
<div className='cvat-objects-sidebar-states-list'>
{ sortedStatesID.map((id: number): JSX.Element => (
<ObjectItemContainer
key={id}
clientID={id}
initialCollapsed={statesCollapsedAll}
/>
))}
{sortedStatesID.map(
(id: number): JSX.Element => (
<ObjectItemContainer
objectStates={objectStates}
key={id}
clientID={id}
initialCollapsed={statesCollapsedAll}
/>
),
)}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import CanvasContextMenuComponent from 'components/annotation-page/standard-work

interface StateToProps {
activatedStateID: number | null;
objectStates: any[];
visible: boolean;
top: number;
left: number;
Expand All @@ -21,24 +22,17 @@ interface StateToProps {
function mapStateToProps(state: CombinedState): StateToProps {
const {
annotation: {
annotations: {
activatedStateID,
collapsed,
},
annotations: { activatedStateID, collapsed, states: objectStates },
canvas: {
contextMenu: {
visible,
top,
left,
type,
},
contextMenu: { visible, top, left, type },
},
},
} = state;

return {
activatedStateID,
collapsed: activatedStateID !== null ? collapsed[activatedStateID] : undefined,
objectStates,
visible,
left,
top,
Expand Down Expand Up @@ -76,8 +70,7 @@ class CanvasContextMenuContainer extends React.PureComponent<Props, State> {
}

static getDerivedStateFromProps(props: Props, state: State): State | null {
if (props.left === state.latestLeft
&& props.top === state.latestTop) {
if (props.left === state.latestLeft && props.top === state.latestTop) {
return null;
}

Expand All @@ -100,9 +93,13 @@ class CanvasContextMenuContainer extends React.PureComponent<Props, State> {

const [element] = window.document.getElementsByClassName('cvat-canvas-context-menu');
if (collapsed !== prevProps.collapsed && element) {
element.addEventListener('transitionend', () => {
this.updatePositionIfOutOfScreen();
}, { once: true });
element.addEventListener(
'transitionend',
() => {
this.updatePositionIfOutOfScreen();
},
{ once: true },
);
} else if (element) {
this.updatePositionIfOutOfScreen();
}
Expand Down Expand Up @@ -145,15 +142,9 @@ class CanvasContextMenuContainer extends React.PureComponent<Props, State> {
};

private updatePositionIfOutOfScreen(): void {
const {
top,
left,
} = this.state;
const { top, left } = this.state;

const {
innerWidth,
innerHeight,
} = window;
const { innerWidth, innerHeight } = window;

const [element] = window.document.getElementsByClassName('cvat-canvas-context-menu');
if (element) {
Expand All @@ -170,24 +161,17 @@ class CanvasContextMenuContainer extends React.PureComponent<Props, State> {
}

public render(): JSX.Element {
const {
left,
top,
} = this.state;

const {
visible,
activatedStateID,
type,
} = this.props;
const { left, top } = this.state;
const { visible, activatedStateID, objectStates, type } = this.props;

return (
<>
{ type === ContextMenuType.CANVAS_SHAPE && (
{type === ContextMenuType.CANVAS_SHAPE && (
<CanvasContextMenuComponent
left={left}
top={top}
visible={visible}
objectStates={objectStates}
activatedStateID={activatedStateID}
/>
)}
Expand All @@ -196,6 +180,4 @@ class CanvasContextMenuContainer extends React.PureComponent<Props, State> {
}
}

export default connect(
mapStateToProps,
)(CanvasContextMenuContainer);
export default connect(mapStateToProps)(CanvasContextMenuContainer);
Loading