File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -2467,17 +2467,17 @@ export class WorkspaceSvg
24672467 * valid gesture exists.
24682468 * @internal
24692469 */
2470- getGesture ( e : PointerEvent ) : Gesture | null {
2470+ getGesture ( e ? : PointerEvent ) : Gesture | null {
24712471 // TODO(#8960): Query Mover.isMoving to see if move is in progress
24722472 // rather than relying on .keyboardMoveInProgress status flag.
24732473 if ( this . keyboardMoveInProgress ) {
24742474 // Normally these would be called from Gesture.doStart.
2475- e . preventDefault ( ) ;
2476- e . stopPropagation ( ) ;
2475+ e ? .preventDefault ( ) ;
2476+ e ? .stopPropagation ( ) ;
24772477 return null ;
24782478 }
24792479
2480- const isStart = e . type === 'pointerdown' ;
2480+ const isStart = e ? .type === 'pointerdown' ;
24812481 if ( isStart && this . currentGesture_ ?. hasStarted ( ) ) {
24822482 console . warn ( 'Tried to start the same gesture twice.' ) ;
24832483 // That's funny. We must have missed a mouse up.
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
1616 sharedTestSetup ,
1717 sharedTestTeardown ,
1818} from './test_helpers/setup_teardown.js' ;
19+ import { dispatchPointerEvent } from './test_helpers/user_input.js' ;
1920import { testAWorkspace } from './test_helpers/workspace.js' ;
2021
2122suite ( 'WorkspaceSvg' , function ( ) {
@@ -114,6 +115,17 @@ suite('WorkspaceSvg', function () {
114115 assert . equal ( true , shadowBlock . isDeadOrDying ( ) ) ;
115116 } ) ;
116117
118+ test ( 'getGesture returns null when no gesture is in progress' , function ( ) {
119+ const gesture = this . workspace . getGesture ( ) ;
120+ assert . isNull ( gesture ) ;
121+ } ) ;
122+
123+ test ( 'getGesture returns the current gesture when one is in progress' , function ( ) {
124+ dispatchPointerEvent ( this . workspace . getSvgGroup ( ) , 'pointerdown' ) ;
125+ const gesture = this . workspace . getGesture ( ) ;
126+ assert . isNotNull ( gesture ) ;
127+ } ) ;
128+
117129 suite ( 'updateToolbox' , function ( ) {
118130 test ( 'Passes in null when toolbox exists' , function ( ) {
119131 assert . throws (
You can’t perform that action at this time.
0 commit comments