Skip to content

Do not reset zoom when switching between workspaces #9233

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

Merged
merged 5 commits into from
Mar 31, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import CanvasWrapper3DComponent, {
} from 'components/annotation-page/canvas/views/canvas3d/canvas-wrapper3D';
import ContextImage from 'components/annotation-page/canvas/views/context-image/context-image';
import CVATTooltip from 'components/common/cvat-tooltip';
import { useUpdateEffect } from 'utils/hooks';
import defaultLayout, { ItemLayout, ViewType } from './canvas-layout.conf';

const ReactGridLayout = WidthProvider(RGL);
Expand Down Expand Up @@ -197,7 +198,7 @@ function CanvasLayout({ type }: { type?: DimensionType }): JSX.Element {
setRowHeight(computeRowHeight());
}, []);

useEffect(() => {
useUpdateEffect(() => {
window.dispatchEvent(new Event('resize'));
}, [layoutConfig]);

Expand Down
14 changes: 14 additions & 0 deletions cvat-ui/src/utils/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import _ from 'lodash';
import {
useRef, useEffect, useState, useCallback,
EffectCallback, DependencyList,
} from 'react';
import { useSelector } from 'react-redux';
import { useHistory } from 'react-router';
Expand Down Expand Up @@ -149,3 +150,16 @@ export function useResetShortcutsOnUnmount(componentShortcuts: Record<string, Ke
registerComponentShortcuts(revertedShortcuts);
}, []);
}

export function useUpdateEffect(effect: EffectCallback, deps?: DependencyList): void {
const isFirstRender = useRef(true);

useEffect(() => {
if (isFirstRender.current) {
isFirstRender.current = false;
return () => {};
}

return effect();
}, deps);
}
9 changes: 7 additions & 2 deletions tests/cypress/e2e/features/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,14 @@ context('Customizable Shortcuts', () => {
cy.get('.cvat-canvas-container').click();
cy.realPress(['F1']);
cy.get('.cvat-shortcuts-modal-window').should('exist').and('be.visible');
cy.get('.cvat-shortcuts-modal-window .ant-pagination-item-5').click();
cy.get('.cvat-shortcuts-modal-window .ant-pagination-options-size-changer').click();
cy.get('.ant-select-dropdown')
.not('.ant-select-dropdown-hidden')
.within(() => {
cy.contains('100 / page').click();
});
checkShortcutsMounted((i) => `Switch label to label ${i}`);
cy.realPress(['F1']);
cy.contains('.cvat-shortcuts-modal-window [type="button"]', 'OK').click();
});
});
});
Loading