fix: adding partial group to frame (#9014)

* prevent new frame from including partial groups

* separate wrapped partial group
This commit is contained in:
Ryan Di
2025-01-23 07:26:12 +08:00
committed by GitHub
parent dd1b45a25a
commit 0bf234fcc9
2 changed files with 70 additions and 3 deletions
@@ -12,6 +12,8 @@ import { frameToolIcon } from "../components/icons";
import { StoreAction } from "../store";
import { getSelectedElements } from "../scene";
import { newFrameElement } from "../element/newElement";
import { getElementsInGroup } from "../groups";
import { mutateElement } from "../element/mutateElement";
const isSingleFrameSelected = (
appState: UIAppState,
@@ -174,6 +176,26 @@ export const actionWrapSelectionInFrame = register({
height: y2 - y1 + PADDING * 2,
});
// for a selected partial group, we want to remove it from the remainder of the group
if (appState.editingGroupId) {
const elementsInGroup = getElementsInGroup(
selectedElements,
appState.editingGroupId,
);
for (const elementInGroup of elementsInGroup) {
const index = elementInGroup.groupIds.indexOf(appState.editingGroupId);
mutateElement(
elementInGroup,
{
groupIds: elementInGroup.groupIds.slice(0, index),
},
false,
);
}
}
const nextElements = addElementsToFrame(
[...app.scene.getElementsIncludingDeleted(), frame],
selectedElements,