This commit is contained in:
Steve Ruiz 2021-11-27 16:21:45 +00:00
commit f15ba31095

View file

@ -1,10 +1,8 @@
import type { Action } from 'state/constants'
import type { TLPointerInfo } from '@tldraw/core'
import { getPagePoint } from 'state/helpers'
import { getShapeUtils } from 'shapes'
import { mutables } from 'state/mutables'
export const eraseShapesAtPoint: Action = (data, payload: TLPointerInfo) => {
export const eraseShapesAtPoint: Action = (data) => {
const { currentPoint } = mutables
Object.values(data.page.shapes).forEach((shape) => {
@ -12,4 +10,17 @@ export const eraseShapesAtPoint: Action = (data, payload: TLPointerInfo) => {
delete data.page.shapes[shape.id]
}
})
const { shapes } = data.page
const { selectedIds, hoveredId } = data.pageState
// Filter out any deleted shapes
data.pageState.selectedIds = selectedIds.filter((id) => {
return shapes[id] !== undefined
})
// Remove hovered id if it's been deleted
if (hoveredId && !shapes[hoveredId]) {
data.pageState.hoveredId = undefined
}
}