fix: stale editing state

This commit is contained in:
Peng Xiao
2022-08-17 16:38:39 +08:00
parent d5bc3cba97
commit f45f0c2170
3 changed files with 7 additions and 4 deletions

View File

@@ -59,13 +59,13 @@ export class CreatingState extends TLToolState<
onExit = () => {
if (!this.creatingShape) return
this.app.clearEditingShape()
this.app.history.resume()
if (this.creatingShape?.props.pageId) {
this.app.setSelectedShapes([this.creatingShape.id])
} else {
this.app.deleteShapes([this.creatingShape.id])
this.app.clearEditingShape()
}
}
}

View File

@@ -529,6 +529,9 @@ export class TLApp<
} else {
this.selectionRotation = 0
}
if (shapes.length === 0) {
this.clearEditingShape()
}
return this
}

View File

@@ -20,6 +20,9 @@ export class EditingShapeState<
onExit = () => {
this.app.persist()
this.app.clearEditingShape()
// Blur all inputs when exit idle
document.querySelectorAll<HTMLElement>('input,textarea').forEach(el => el.blur())
}
onPointerDown: TLEvents<S>['pointer'] = info => {
@@ -51,9 +54,6 @@ export class EditingShapeState<
e.stopPropagation()
this.app.setSelectedShapes([this.editingShape])
this.tool.transition('idle')
// Blur all inputs when exit idle
document.querySelectorAll<HTMLElement>('input,textarea').forEach(el => el.blur())
})
break
}