mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: regression in indexing when adding elements to frame (#6904)
This commit is contained in:
parent
9cd5e15917
commit
de1ebad755
3 changed files with 141 additions and 10 deletions
12
src/frame.ts
12
src/frame.ts
|
@ -469,14 +469,6 @@ export const addElementsToFrame = (
|
|||
}
|
||||
|
||||
let nextElements = allElements.slice();
|
||||
// Optimisation since findIndex on "newElements" is slow
|
||||
const nextElementsIndex = nextElements.reduce(
|
||||
(acc: Record<string, number | undefined>, element, index) => {
|
||||
acc[element.id] = index;
|
||||
return acc;
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
const frameBoundary = findIndex(nextElements, (e) => e.frameId === frame.id);
|
||||
for (const element of omitGroupsContainingFrames(
|
||||
|
@ -492,8 +484,8 @@ export const addElementsToFrame = (
|
|||
false,
|
||||
);
|
||||
|
||||
const frameIndex = nextElementsIndex[frame.id] ?? -1;
|
||||
const elementIndex = nextElementsIndex[element.id] ?? -1;
|
||||
const frameIndex = findIndex(nextElements, (e) => e.id === frame.id);
|
||||
const elementIndex = findIndex(nextElements, (e) => e.id === element.id);
|
||||
|
||||
if (elementIndex < frameBoundary) {
|
||||
nextElements = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue