feat(WorkspaceSvg): Ignore gestures when keyboard move in progress (#8963)

* feat(WorkspaceSvg): Ignore gestures during keyboard moves

  Modify WorkspaceSvg.prototype.getGesture to return null when
  there is a keyboard-initiated move in progress.

* chore(WorkspaceSvg): Add TODOs to remove .keyboardMoveInProgress
This commit is contained in:
Christopher Allen
2025-05-03 00:21:41 +01:00
committed by GitHub
parent a4e6166ca8
commit bc0e1c3ca3

View File

@@ -314,7 +314,7 @@ export class WorkspaceSvg
keyboardAccessibilityMode = false;
/** True iff a keyboard-initiated move ("drag") is in progress. */
keyboardMoveInProgress = false;
keyboardMoveInProgress = false; // TODO(#8960): Delete this.
/** The list of top-level bounded elements on the workspace. */
private topBoundedElements: IBoundedElement[] = [];
@@ -1471,6 +1471,8 @@ export class WorkspaceSvg
* removed, at an time without notice and without being treated
* as a breaking change.
*
* TODO(#8960): Delete this.
*
* @internal
* @param inProgress Is a keyboard-initated move in progress?
*/
@@ -1494,6 +1496,8 @@ export class WorkspaceSvg
*/
isDragging(): boolean {
return (
// TODO(#8960): Query Mover.isMoving to see if move is in
// progress rather than relying on a status flag.
this.keyboardMoveInProgress ||
(this.currentGesture_ !== null && this.currentGesture_.isDragging())
);
@@ -2403,7 +2407,17 @@ export class WorkspaceSvg
/**
* Look up the gesture that is tracking this touch stream on this workspace.
* May create a new gesture.
*
* Returns the gesture in progress, except:
*
* - If there is a keyboard-initiate move in progress then null will
* be returned - after calling event.preventDefault() and
* event.stopPropagation() to ensure the pointer event is ignored.
* - If there is a gesture in progress but event.type is
* 'pointerdown' then the in-progress gesture will be cancelled;
* this will result in null being returned.
* - If no gesutre is in progress but event is a pointerdown then a
* new gesture will be created and returned.
*
* @param e Pointer event.
* @returns The gesture that is tracking this touch stream, or null if no
@@ -2411,28 +2425,29 @@ export class WorkspaceSvg
* @internal
*/
getGesture(e: PointerEvent): Gesture | null {
// TODO(#8960): Query Mover.isMoving to see if move is in progress
// rather than relying on .keyboardMoveInProgress status flag.
if (this.keyboardMoveInProgress) {
// Normally these would be called from Gesture.doStart.
e.preventDefault();
e.stopPropagation();
return null;
}
const isStart = e.type === 'pointerdown';
const gesture = this.currentGesture_;
if (gesture) {
if (isStart && gesture.hasStarted()) {
console.warn('Tried to start the same gesture twice.');
// That's funny. We must have missed a mouse up.
// Cancel it, rather than try to retrieve all of the state we need.
gesture.cancel();
return null;
}
return gesture;
if (isStart && this.currentGesture_?.hasStarted()) {
console.warn('Tried to start the same gesture twice.');
// That's funny. We must have missed a mouse up.
// Cancel it, rather than try to retrieve all of the state we need.
this.currentGesture_.cancel(); // Sets this.currentGesture_ to null.
}
// No gesture existed on this workspace, but this looks like the start of a
// new gesture.
if (isStart) {
if (!this.currentGesture_ && isStart) {
// No gesture existed on this workspace, but this looks like the
// start of a new gesture.
this.currentGesture_ = new Gesture(e, this);
return this.currentGesture_;
}
// No gesture existed and this event couldn't be the start of a new gesture.
return null;
return this.currentGesture_;
}
/**