[fix] line tool bug with tool locked (#1841)
This PR fixes a bug where tool lock would cause the line tool to not work properly. ### Change Type - [x] `patch` — Bug fix ### Test Plan 1. Turn on tool lock. 2. Draw two line shapes - [x] Unit Tests
This commit is contained in:
parent
249bacf50b
commit
e7ad05fbf5
2 changed files with 59 additions and 44 deletions
|
@ -209,3 +209,20 @@ describe('When extending the line with the shift-key in tool-lock mode', () => {
|
||||||
expect(handles.length).toBe(3)
|
expect(handles.length).toBe(3)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('tool lock bug', () => {
|
||||||
|
it('works as expected when tool lock is on but shift is off', () => {
|
||||||
|
expect(editor.currentPageShapes.length).toBe(0)
|
||||||
|
editor
|
||||||
|
.updateInstanceState({ isToolLocked: true })
|
||||||
|
.setCurrentTool('line')
|
||||||
|
.pointerDown(0, 0)
|
||||||
|
.pointerMove(10, 10)
|
||||||
|
.pointerUp(10, 10)
|
||||||
|
.pointerDown(100, 100)
|
||||||
|
.pointerMove(110, 110)
|
||||||
|
.pointerUp(100, 100)
|
||||||
|
.pointerUp(120, 110)
|
||||||
|
expect(editor.currentPageShapes.length).toBe(2)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
|
@ -29,12 +29,11 @@ export class Pointing extends StateNode {
|
||||||
|
|
||||||
const shape = info.shapeId && this.editor.getShape<TLLineShape>(info.shapeId)
|
const shape = info.shapeId && this.editor.getShape<TLLineShape>(info.shapeId)
|
||||||
|
|
||||||
if (shape) {
|
if (shape && inputs.shiftKey) {
|
||||||
this.markId = `creating:${shape.id}`
|
this.markId = `creating:${shape.id}`
|
||||||
this.editor.mark(this.markId)
|
this.editor.mark(this.markId)
|
||||||
this.shape = shape
|
this.shape = shape
|
||||||
|
|
||||||
if (inputs.shiftKey) {
|
|
||||||
const handles = this.editor.getShapeHandles(this.shape)
|
const handles = this.editor.getShapeHandles(this.shape)
|
||||||
if (!handles) return
|
if (!handles) return
|
||||||
|
|
||||||
|
@ -82,7 +81,6 @@ export class Pointing extends StateNode {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const id = createShapeId()
|
const id = createShapeId()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue