Fix spacebar/mmb panning bug. (#3791)

We had a bug in our inputs logic that would allow a long press timeout
to be triggered if a user started pointing before holding spacebar. This
PR fixes that bug! Thanks to @ds300 for the spot.

### Change Type

- [x] `sdk` — Changes the tldraw SDK
- [x] `bugfix` — Bug fix

### Release Notes

- Fix bug with panning
This commit is contained in:
Steve Ruiz 2024-05-21 10:29:28 +01:00 committed by GitHub
parent 18b03624d5
commit 625d59e468
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8543,10 +8543,16 @@ export class Editor extends EventEmitter<TLEventMap> {
// Close any open menus
this.clearOpenMenus()
// Start a long press timeout
this._longPressTimeout = setTimeout(() => {
this.dispatch({ ...info, name: 'long_press' })
}, LONG_PRESS_DURATION)
if (!this.inputs.isPanning) {
// Start a long press timeout
this._longPressTimeout = setTimeout(() => {
this.dispatch({
...info,
point: this.inputs.currentScreenPoint,
name: 'long_press',
})
}, LONG_PRESS_DURATION)
}
// Save the selected ids at pointer down
this._selectedShapeIdsAtPointerDown = this.getSelectedShapeIds()