refactor: improve typing & check (#5415)

This commit is contained in:
David Luzar 2022-07-19 15:44:04 +02:00 committed by GitHub
parent ba16416c75
commit 792f238d16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 26 deletions

View file

@ -1540,12 +1540,15 @@ class App extends React.Component<AppProps, AppState> {
this.state.isLibraryOpen && this.device.canDeviceFitSidebar
? this.state.isLibraryMenuDocked
: false,
selectedElementIds: newElements.reduce((map, element) => {
if (!isBoundToContainer(element)) {
map[element.id] = true;
}
return map;
}, {} as any),
selectedElementIds: newElements.reduce(
(acc: Record<ExcalidrawElement["id"], true>, element) => {
if (!isBoundToContainer(element)) {
acc[element.id] = true;
}
return acc;
},
{},
),
selectedGroupIds: {},
},
this.scene.getNonDeletedElements(),
@ -4307,10 +4310,13 @@ class App extends React.Component<AppProps, AppState> {
...prevState,
selectedElementIds: {
...prevState.selectedElementIds,
...elementsWithinSelection.reduce((map, element) => {
map[element.id] = true;
return map;
}, {} as any),
...elementsWithinSelection.reduce(
(acc: Record<ExcalidrawElement["id"], true>, element) => {
acc[element.id] = true;
return acc;
},
{},
),
...(pointerDownState.hit.element
? {
// if using ctrl/cmd, select the hitElement only if we