mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: make appState.selectedElementIds
more stable (#6745)
This commit is contained in:
parent
3ddcc48e4c
commit
49e4289878
15 changed files with 503 additions and 295 deletions
|
@ -218,6 +218,7 @@ export const actionUngroup = register({
|
|||
const updateAppState = selectGroupsForSelectedElements(
|
||||
{ ...appState, selectedGroupIds: {} },
|
||||
getNonDeletedElements(nextElements),
|
||||
appState,
|
||||
);
|
||||
|
||||
frames.forEach((frame) => {
|
||||
|
@ -232,9 +233,18 @@ export const actionUngroup = register({
|
|||
});
|
||||
|
||||
// remove binded text elements from selection
|
||||
boundTextElementIds.forEach(
|
||||
(id) => (updateAppState.selectedElementIds[id] = false),
|
||||
updateAppState.selectedElementIds = Object.entries(
|
||||
updateAppState.selectedElementIds,
|
||||
).reduce(
|
||||
(acc: { [key: ExcalidrawElement["id"]]: true }, [id, selected]) => {
|
||||
if (selected && !boundTextElementIds.includes(id)) {
|
||||
acc[id] = true;
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
return {
|
||||
appState: updateAppState,
|
||||
elements: nextElements,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue