Ver Fonte

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 há 6 anos atrás
pai
commit
03c6d3f078
1 ficheiros alterados com 10 adições e 2 exclusões
  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();
+      }
+    }
   }
 
   /**