@@ -56,9 +56,7 @@ export class EnterAction {
5656 preconditionFn : ( workspace ) : boolean => {
5757 switch ( this . navigation . getState ( ) ) {
5858 case Constants . STATE . WORKSPACE :
59- // The main workspace may or may not handle it depending on what's
60- // selected, so always pass it through to the callback.
61- return true ;
59+ return this . shouldHandleEnterForWS ( workspace ) ;
6260 case Constants . STATE . FLYOUT : {
6361 // If we're in the flyout the only supported actions are inserting
6462 // blocks or clicking buttons, so don't handle this if the
@@ -87,7 +85,6 @@ export class EnterAction {
8785 case Constants . STATE . WORKSPACE :
8886 return this . handleEnterForWS ( workspace ) ;
8987 case Constants . STATE . FLYOUT :
90- if ( targetWorkspace . isReadOnly ( ) ) return false ;
9188 flyoutCursor = this . navigation . getFlyoutCursor ( targetWorkspace ) ;
9289 if ( ! flyoutCursor ) {
9390 return false ;
@@ -107,6 +104,21 @@ export class EnterAction {
107104 } ) ;
108105 }
109106
107+ /**
108+ * Checks if the enter key should do anything for this ws.
109+ *
110+ * @param workspace The workspace to check.
111+ * @returns True if the enter action should be handled.
112+ */
113+ private shouldHandleEnterForWS ( workspace : WorkspaceSvg ) : boolean {
114+ const cursor = workspace . getCursor ( ) ;
115+ const curNode = cursor ?. getCurNode ( ) ;
116+ if ( ! curNode ) return false ;
117+ if ( curNode instanceof Field && ! curNode . isClickable ( ) ) return false ;
118+ // Returning true is sometimes incorrect for icons, but there's no API to check.
119+ return true ;
120+ }
121+
110122 /**
111123 * Handles hitting the enter key on the workspace.
112124 *
@@ -115,8 +127,7 @@ export class EnterAction {
115127 */
116128 private handleEnterForWS ( workspace : WorkspaceSvg ) : boolean {
117129 const cursor = workspace . getCursor ( ) ;
118- if ( ! cursor ) return false ;
119- const curNode = cursor . getCurNode ( ) ;
130+ const curNode = cursor ?. getCurNode ( ) ;
120131 if ( ! curNode ) return false ;
121132 if ( curNode instanceof Field ) {
122133 curNode . showEditor ( ) ;
@@ -297,7 +308,7 @@ export class EnterAction {
297308 if ( block . isSimpleReporter ( ) ) {
298309 for ( const input of block . inputList ) {
299310 for ( const field of input . fieldRow ) {
300- if ( field . isFullBlockField ( ) ) {
311+ if ( field . isClickable ( ) && field . isFullBlockField ( ) ) {
301312 field . showEditor ( ) ;
302313 return true ;
303314 }
0 commit comments