diff --git a/.changeset/spotty-mayflies-rescue.md b/.changeset/spotty-mayflies-rescue.md new file mode 100644 index 000000000..8d8a5eced --- /dev/null +++ b/.changeset/spotty-mayflies-rescue.md @@ -0,0 +1,5 @@ +--- +'@plait/core': patch +--- + +return null when hover selected element diff --git a/packages/core/src/utils/group.ts b/packages/core/src/utils/group.ts index aa2cdb1e0..77ba0c1b1 100644 --- a/packages/core/src/utils/group.ts +++ b/packages/core/src/utils/group.ts @@ -176,13 +176,16 @@ export const getHighestSelectedElements = (board: PlaitBoard, elements?: PlaitEl }; export const createGroupRectangleG = (board: PlaitBoard, elements: PlaitElement[]): SVGGElement | null => { - const selectedElements = getSelectedElements(board); - const groupRectangleG: SVGGElement = createG(); + const selectedElementIds = getSelectedElements(board).map(item => item.id); + let groupRectangleG: SVGGElement | null = null; const isMoving = isSelectionMoving(board); elements.forEach(item => { - const isRender = (!selectedElements.includes(item) && !isMoving) || isMoving; + const isRender = (!selectedElementIds.includes(item.id) && !isMoving) || isMoving; if (item.groupId && isRender) { + if (!groupRectangleG) { + groupRectangleG = createG(); + } const elements = getElementsInGroupByElement(board, item); const rectangle = getRectangleByElements(board, elements, false); const rectangleG = drawRectangle(board, rectangle, {