Fixed bug related to locked tools & select tool (#331)

This commit is contained in:
Proful Sadangi 2021-11-21 22:53:13 +11:00 committed by GitHub
parent 3f674d7fa5
commit a1f4149efe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -87,6 +87,7 @@ export const PrimaryTools = React.memo(function PrimaryTools(): JSX.Element {
kbd={'7'} kbd={'7'}
label={TDShapeType.Text} label={TDShapeType.Text}
onClick={selectTextTool} onClick={selectTextTool}
isLocked={isToolLocked}
isActive={activeTool === TDShapeType.Text} isActive={activeTool === TDShapeType.Text}
> >
<TextIcon /> <TextIcon />

View file

@ -1839,9 +1839,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
this.addToSelectHistory(this.selectedIds) this.addToSelectHistory(this.selectedIds)
if (this.appState.activeTool !== 'select') { this.selectTool('select')
this.selectTool('select')
}
return this return this
} }
@ -2730,6 +2728,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
if (Date.now() - this.editingStartTime < 50) return if (Date.now() - this.editingStartTime < 50) return
const { editingId } = this.pageState const { editingId } = this.pageState
const { isToolLocked } = this.getAppState()
if (editingId) { if (editingId) {
// If we're editing text, then delete the text if it's empty // If we're editing text, then delete the text if it's empty
@ -2738,7 +2737,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
if (shape.type === TDShapeType.Text) { if (shape.type === TDShapeType.Text) {
if (shape.text.trim().length <= 0) { if (shape.text.trim().length <= 0) {
this.patchState(Commands.deleteShapes(this, [editingId]).after, 'delete_empty_text') this.patchState(Commands.deleteShapes(this, [editingId]).after, 'delete_empty_text')
} else { } else if (!isToolLocked) {
this.select(editingId) this.select(editingId)
} }
} }