File tree Expand file tree Collapse file tree 3 files changed +20
-17
lines changed
Expand file tree Collapse file tree 3 files changed +20
-17
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,8 @@ export class EnterAction {
6464 const targetWorkspace = workspace . isFlyout
6565 ? workspace . targetWorkspace
6666 : workspace ;
67- return ! ! targetWorkspace && ! targetWorkspace . isReadOnly ( ) ;
67+ if ( ! targetWorkspace ) return false ;
68+ return this . navigation . canCurrentlyEdit ( targetWorkspace ) ;
6869 }
6970 default :
7071 return false ;
@@ -111,6 +112,8 @@ export class EnterAction {
111112 * @returns True if the enter action should be handled.
112113 */
113114 private shouldHandleEnterForWS ( workspace : WorkspaceSvg ) : boolean {
115+ if ( ! this . navigation . canCurrentlyNavigate ( workspace ) ) return false ;
116+
114117 const cursor = workspace . getCursor ( ) ;
115118 const curNode = cursor ?. getCurNode ( ) ;
116119 if ( ! curNode ) return false ;
Original file line number Diff line number Diff line change @@ -96,7 +96,12 @@ export class Navigation {
9696 * @returns The state of the given workspace.
9797 */
9898 getState ( ) : Constants . STATE {
99- const focusedTree = Blockly . getFocusManager ( ) . getFocusedTree ( ) ;
99+ const focusManager = Blockly . getFocusManager ( ) ;
100+ if ( focusManager . ephemeralFocusTaken ( ) ) {
101+ return Constants . STATE . NOWHERE ;
102+ }
103+
104+ const focusedTree = focusManager . getFocusedTree ( ) ;
100105 if ( focusedTree instanceof Blockly . WorkspaceSvg ) {
101106 if ( focusedTree . isFlyout ) {
102107 return Constants . STATE . FLYOUT ;
@@ -837,11 +842,7 @@ export class Navigation {
837842 workspace . targetWorkspace ??
838843 workspace
839844 ) . keyboardAccessibilityMode ;
840- return (
841- ! ! accessibilityMode &&
842- this . getState ( ) !== Constants . STATE . NOWHERE &&
843- ! Blockly . getFocusManager ( ) . ephemeralFocusTaken ( )
844- ) ;
845+ return ! ! accessibilityMode && this . getState ( ) !== Constants . STATE . NOWHERE ;
845846 }
846847
847848 /**
@@ -854,7 +855,7 @@ export class Navigation {
854855 * @returns whether keyboard navigation and editing is currently allowed.
855856 */
856857 canCurrentlyEdit ( workspace : Blockly . WorkspaceSvg ) {
857- return this . canCurrentlyNavigate ( workspace ) && ! workspace . options . readOnly ;
858+ return this . canCurrentlyNavigate ( workspace ) && ! workspace . isReadOnly ( ) ;
858859 }
859860
860861 /**
Original file line number Diff line number Diff line change @@ -375,15 +375,14 @@ suite('Keyboard navigation on Fields', function () {
375375 await keyRight ( this . browser ) ;
376376 // Enter to choose.
377377 await this . browser . keys ( Key . Enter ) ;
378- await this . browser . pause ( 1000 ) ;
379-
380- // Check that browser focus is back on the colour block, not e.g. a widget
381- // or dropdown div. Not sufficient to check with the focus manager.
382- // TODO: fix and flip.
383- chai . assert . isFalse (
384- await this . browser . execute ( ( ) =>
385- document . activeElement ?. classList . contains ( 'blocklyActiveFocus' ) ,
386- ) ,
378+
379+ // Focus seems to take longer than a single pause to settle.
380+ await this . browser . waitUntil (
381+ ( ) =>
382+ this . browser . execute ( ( ) =>
383+ document . activeElement ?. classList . contains ( 'blocklyActiveFocus' ) ,
384+ ) ,
385+ { timeout : 1000 } ,
387386 ) ;
388387 } ) ;
389388} ) ;
You can’t perform that action at this time.
0 commit comments