Bläddra i källkod

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 år sedan
förälder
incheckning
03c6d3f078
1 ändrade filer med 10 tillägg och 2 borttagningar
  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();
+      }
+    }
   }
 
   /**