This PR fixes a bug in the nudge code. The offset was previously mutated
in a loop by a `Vec.Cast`.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Select some shapes
2. nudge em

- [x] Unit Tests

### Release Notes

- Fixes a bug with keyboard nudging.
lu/inline-component
Steve Ruiz 2024-01-25 14:20:20 +00:00 zatwierdzone przez GitHub
rodzic 5953b1cdd4
commit 3577cf1ca6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -5133,7 +5133,7 @@ export class Editor extends EventEmitter<TLEventMap> {
for (const id of ids) {
const shape = this.getShape(id)!
const localDelta = Vec.Cast(offset)
const localDelta = Vec.From(offset)
const parentTransform = this.getShapeParentTransform(shape)
if (parentTransform) localDelta.rot(-parentTransform.rotation())

Wyświetl plik

@ -1,4 +1,4 @@
import { TLShapeId, createShapeId } from '@tldraw/editor'
import { TLShapeId, Vec, createShapeId } from '@tldraw/editor'
import { TestEditor } from '../TestEditor'
let editor: TestEditor
@ -39,22 +39,22 @@ function nudgeAndGet(ids: TLShapeId[], key: string, shiftKey: boolean) {
switch (key) {
case 'ArrowLeft': {
editor.mark('nudge')
editor.nudgeShapes(editor.getSelectedShapeIds(), { x: -step, y: 0 })
editor.nudgeShapes(editor.getSelectedShapeIds(), new Vec(-step, 0))
break
}
case 'ArrowRight': {
editor.mark('nudge')
editor.nudgeShapes(editor.getSelectedShapeIds(), { x: step, y: 0 })
editor.nudgeShapes(editor.getSelectedShapeIds(), new Vec(step, 0))
break
}
case 'ArrowUp': {
editor.mark('nudge')
editor.nudgeShapes(editor.getSelectedShapeIds(), { x: 0, y: -step })
editor.nudgeShapes(editor.getSelectedShapeIds(), new Vec(0, -step))
break
}
case 'ArrowDown': {
editor.mark('nudge')
editor.nudgeShapes(editor.getSelectedShapeIds(), { x: 0, y: step })
editor.nudgeShapes(editor.getSelectedShapeIds(), new Vec(0, step))
break
}
}