Browse Source

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

main
Proful Sadangi 3 years ago
parent
commit
a1f4149efe
No account linked to committer's email address

+ 1
- 0
packages/tldraw/src/components/ToolsPanel/PrimaryTools.tsx View File

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

+ 3
- 4
packages/tldraw/src/state/TldrawApp.ts View File

@@ -1839,9 +1839,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
1839 1839
 
1840 1840
     this.addToSelectHistory(this.selectedIds)
1841 1841
 
1842
-    if (this.appState.activeTool !== 'select') {
1843
-      this.selectTool('select')
1844
-    }
1842
+    this.selectTool('select')
1845 1843
 
1846 1844
     return this
1847 1845
   }
@@ -2730,6 +2728,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
2730 2728
     if (Date.now() - this.editingStartTime < 50) return
2731 2729
 
2732 2730
     const { editingId } = this.pageState
2731
+    const { isToolLocked } = this.getAppState()
2733 2732
 
2734 2733
     if (editingId) {
2735 2734
       // If we're editing text, then delete the text if it's empty
@@ -2738,7 +2737,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
2738 2737
       if (shape.type === TDShapeType.Text) {
2739 2738
         if (shape.text.trim().length <= 0) {
2740 2739
           this.patchState(Commands.deleteShapes(this, [editingId]).after, 'delete_empty_text')
2741
-        } else {
2740
+        } else if (!isToolLocked) {
2742 2741
           this.select(editingId)
2743 2742
         }
2744 2743
       }

Loading…
Cancel
Save