Browse Source

Fix focus issues when focusing away from a notebook in edit mode.

To see the problem, edit a cell in a notebook, then click on the command palette search box. The focus does not end up at the search box, but instead ends up on the notebook node.

Perhaps the one setting the mode should be in charge of setting the focus?
Jason Grout 6 years ago
parent
commit
03c6d3f078
1 changed files with 10 additions and 2 deletions
  1. 10 2
      packages/notebook/src/widget.ts

+ 10 - 2
packages/notebook/src/widget.ts

@@ -2056,8 +2056,16 @@ export class Notebook extends StaticNotebook {
       }
     }
 
-    // Otherwise enter command mode.
-    this.mode = 'command';
+    // Otherwise enter command mode if not already.
+    if (this.mode !== 'command') {
+      this.mode = 'command';
+
+      // Switching to command mode currently focuses the notebook element, so
+      // refocus the relatedTarget so the focus actually switches as intended.
+      if (relatedTarget) {
+        relatedTarget.focus();
+      }
+    }
   }
 
   /**