Parcourir la 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 il y a 6 ans
Parent
commit
03c6d3f078
1 fichiers modifiés avec 10 ajouts et 2 suppressions
  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();
+      }
+    }
   }
 
   /**