Skip to content
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
13 changes: 6 additions & 7 deletions client/dive-common/use/useModeManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ describe('entering polygon editing', () => {
});

describe('confirming a point segmentation', () => {
it('leaves edit mode with the detection still selected, and removes one with nothing drawn', () => {
it('deselects the detection, and removes one with nothing drawn', () => {
const recipe = new SegmentationPointClick();
const { modeManager: manager, cameraStore } = makeHarness(undefined, [recipe]);
recipe.activate();
Expand All @@ -770,9 +770,10 @@ describe('confirming a point segmentation', () => {
manager.handler.trackEdit(drawn);
recipe.resetPoints();
manager.handler.confirmRecipe();
expect(manager.selectedTrackId.value).toBe(drawn);
expect(manager.selectedTrackId.value).toBeNull();
expect(manager.editingTrack.value).toBe(false);
expect(recipe.active.value).toBe(true);
expect(cameraStore.getPossibleTrack(drawn, 'left')).toBeDefined();

const empty = manager.handler.trackAdd();
recipe.resetPoints();
Expand Down Expand Up @@ -830,22 +831,20 @@ describe('a right-click that enters point segmentation editing', () => {
manager.handler.confirmRecipe();
expect(manager.selectedTrackId.value).toBe(first);
expect(manager.editingTrack.value).toBe(true);
// A later right-click with no points placed leaves edit mode with the
// detection still selected, as the other annotation types do.
// A later right-click with no points placed finalizes and deselects it.
press();
manager.handler.confirmRecipe();
expect(manager.selectedTrackId.value).toBe(first);
expect(manager.selectedTrackId.value).toBeNull();
expect(manager.editingTrack.value).toBe(false);
// So does one after a reset by the user, even within the same press.
press();
manager.handler.trackEdit(second);
recipe.resetPoints();
expect(recipe.wasReset).toBe(true);
manager.handler.confirmRecipe();
expect(manager.selectedTrackId.value).toBe(second);
expect(manager.selectedTrackId.value).toBeNull();
expect(manager.editingTrack.value).toBe(false);
// With nothing selected a right-click changes nothing.
manager.handler.trackSelect(null, false);
press();
manager.handler.confirmRecipe();
expect(recipe.active.value).toBe(true);
Expand Down
9 changes: 2 additions & 7 deletions client/dive-common/use/useModeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1425,14 +1425,9 @@ export default function useModeManager({
// Re-arm the recipe for the next detection first: activating it
// re-selects the current track in edit mode (handleSetAnnotationState).
activeSegRecipes.forEach((r) => r.activate());
// Then leave edit mode with the detection still selected, as the other
// annotation types do; one with nothing drawn is removed instead.
const confirmedId = selectedTrackId.value;
if (confirmedId !== null && _removeIfEmpty(confirmedId)) {
selectTrack(null, false);
} else {
selectTrack(confirmedId, false);
}
if (confirmedId !== null) _removeIfEmpty(confirmedId);
selectTrack(null, false);
}

/**
Expand Down
Loading