Enhance selection duplication logic and update tests
This commit is contained in:
@@ -2129,7 +2129,15 @@ export function App({ store, initialStatusMessage }) {
|
||||
}
|
||||
try {
|
||||
store.executeCommand(createDuplicateSelectionCommand());
|
||||
setStatusMessage("Duplicated selection.");
|
||||
const duplicatedSelection = store.getState().selection;
|
||||
const canGrabDuplicatedSelection = (duplicatedSelection.kind === "brushes" || duplicatedSelection.kind === "entities" || duplicatedSelection.kind === "modelInstances") &&
|
||||
duplicatedSelection.ids.length === 1;
|
||||
if (canGrabDuplicatedSelection) {
|
||||
beginTransformOperation("translate", "keyboard");
|
||||
}
|
||||
else {
|
||||
setStatusMessage("Duplicated selection.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
@@ -142,6 +142,10 @@ test("shift+d duplicates the current selection and does not trigger while typing
|
||||
kind: "brushes"
|
||||
});
|
||||
expect(Object.keys(afterDuplicateSnapshot.document.brushes)).toHaveLength(2);
|
||||
expect(afterDuplicateSnapshot.viewportTransientState.transformSession).toMatchObject({
|
||||
kind: "active",
|
||||
operation: "translate"
|
||||
});
|
||||
|
||||
const duplicatedBrushId = afterDuplicateSnapshot.selection.ids?.[0];
|
||||
expect(duplicatedBrushId).toBeDefined();
|
||||
|
||||
Reference in New Issue
Block a user