Skip to content

The logic for interacting with 3D annotation layers has been updated#10299

Open
filichabout wants to merge 6 commits intodevelopfrom
ap/DEV-803-shortcut-for-3d-workspace
Open

The logic for interacting with 3D annotation layers has been updated#10299
filichabout wants to merge 6 commits intodevelopfrom
ap/DEV-803-shortcut-for-3d-workspace

Conversation

@filichabout
Copy link
Contributor

Motivation and context

Consistent behaviour for Tab/Shift+Tab on 2D and 3D workspace

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

@codecov-commenter
Copy link

codecov-commenter commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.81%. Comparing base (366c3be) to head (ef8f8a5).
⚠️ Report is 9 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #10299      +/-   ##
===========================================
- Coverage    74.71%   73.81%   -0.90%     
===========================================
  Files          431      432       +1     
  Lines        46654    46705      +51     
  Branches      4220     4230      +10     
===========================================
- Hits         34858    34477     -381     
- Misses       11796    12228     +432     
Components Coverage Δ
cvat-ui 77.68% <77.77%> (-0.02%) ⬇️
cvat-server 70.51% <ø> (-1.66%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

private focusAndExpand = (): void => {
const {
objectState, canvasInstance, focusedObjectPadding, expandObject,
objectState, canvasInstance, focusedObjectPadding,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand behaviour was previously added in this pull request #10172 to improve consensus UX.

On the one hand, I believe it is necessary in review mode, and maybe not necessary in other modes. On the other hand, I do not see reasons to have different behaviour for different workspaces.

So, currently let's revert this change.


if (canvasInstance instanceof Canvas && objectState.objectType !== ObjectType.TAG) {
canvasInstance.focus(objectState.clientID as number, focusedObjectPadding);
} else if (canvasInstance instanceof Canvas3d && objectState.objectType !== ObjectType.TAG) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objectState.objectType !== ObjectType.TAG repeated twice, thus it may be rewritten as:

if (objectState.objectType !== ..) {
if (isCanvas2D) { ... }
else if (isCanvas3D) { ... }
}

MOVE_RIGHT: () => { },
ZOOM_IN: () => { },
ZOOM_OUT: () => { },
NEXT_OBJECT: (event: KeyboardEvent | undefined) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NEXT_OBJECT: (event: KeyboardEvent | undefined) => {
NEXT_OBJECT: (event?: KeyboardEvent) => {

preventDefault(event);
navigateObject(1);
},
PREVIOUS_OBJECT: (event: KeyboardEvent | undefined) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PREVIOUS_OBJECT: (event: KeyboardEvent | undefined) => {
PREVIOUS_OBJECT: (event?: KeyboardEvent) => {

Comment on lines +112 to +114
public focusObject(clientID: number, animate: boolean = true): void {
this.view.focusObjectByClientId(clientID, animate);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May we keep the interface of 2D and 3D canvas similar?

I mean name this method just focus and remove the second parameter animate as in current implementation is always true and seems unnecessary

frameData,
contextMenuVisibility,
annotations,
annotations: annotations as ObjectState[],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would not it be better to fix the typing for the state instead?

keyMap: state.shortcuts.keyMap,
normalizedKeyMap: state.shortcuts.normalizedKeyMap,
annotations: state.annotation.annotations.states as ObjectState[],
activatedStateID: state.annotation.annotations.activatedStateID as number | null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is already number | null. Type case is useless

normalizedKeyMap: state.shortcuts.normalizedKeyMap,
annotations: state.annotation.annotations.states as ObjectState[],
activatedStateID: state.annotation.annotations.activatedStateID as number | null,
curZLayer: state.annotation.annotations.zLayer.cur as number,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already number

canvas.keyControls(new KeyboardEvent('keydown', { code, altKey, shiftKey }));
};

const navigateObject = (step: number): void => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation seems very similar with 2D workspace, do you see any ways to reduce code duplication?

Comment on lines +716 to +726
const objectState = annotations.find((state) => state.clientID === clientID);

if (objectState) {
const sidebarItem = window.document.getElementById(
`cvat-objects-sidebar-state-item-${clientID}`,
);

if (sidebarItem) {
sidebarItem.scrollIntoView();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not be here. When cursor just hovered, view should not be scrolled

onSplitAnnotations(state);
};

const onCanvasDoubleClicked = (event: CustomEvent<{ clientID: number | null }>): void => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's implement the same logic as in onCanvasShapeClicked of 2D canvas when shape just clicked (not doubleclicked, so, event name should be canvas.clicked, to keep naming consistent.

@bsekachev
Copy link
Member

Next object/Previous object shortcuts disappeared from Annotation page section. And now only in 3D workspace section

Before patch:

image

After patch:
image

@filichabout filichabout force-pushed the ap/DEV-803-shortcut-for-3d-workspace branch from 6624ad5 to ddd20fe Compare February 27, 2026 10:16
@@ -0,0 +1,42 @@
import { ObjectState } from 'cvat-core-wrapper';

export function getSidebarItemId(state: ObjectState): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used only internally, not necessary to be exported

return `cvat-objects-sidebar-state-item-${clientID}`;
}

export function scrollSidebarItemIntoViewById(id: string): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used only internally, not necessary to be exported

expandObject(state);
}

export function scrollAndExpandByClientID(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wrapper seems unnecessary as the find logic maybe implemented in calling function (and there is only one place it called from)

@filichabout filichabout force-pushed the ap/DEV-803-shortcut-for-3d-workspace branch from 3d69d02 to 1ff9c4f Compare March 4, 2026 13:32
@filichabout filichabout force-pushed the ap/DEV-803-shortcut-for-3d-workspace branch from 1ff9c4f to 6e9f33a Compare March 4, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants