Browse Source

fix running cell when focused on output (#10517)

Co-authored-by: Cameron Toy <cameron-toy@users.noreply.github.com>
Cameron Toy 3 years ago
parent
commit
671fc2d264
1 changed files with 4 additions and 10 deletions
  1. 4 10
      packages/notebook/src/widget.ts

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

@@ -180,6 +180,7 @@ export class StaticNotebook extends Widget {
     this.addClass(NB_CLASS);
     this.node.dataset[KERNEL_USER] = 'true';
     this.node.dataset[UNDOER] = 'true';
+    this.node.dataset[CODE_RUNNER] = 'true';
     this.rendermime = options.rendermime;
     this.layout = new Private.NotebookPanelLayout();
     this.contentFactory =
@@ -2252,22 +2253,15 @@ export class Notebook extends StaticNotebook {
       // If the editor itself does not have focus, ensure command mode.
       if (!widget.editorWidget.node.contains(target)) {
         this.mode = 'command';
-      }
-      this.activeCellIndex = index;
-      // If the editor has focus, ensure edit mode.
-      const node = widget.editorWidget.node;
-      if (node.contains(target)) {
+      } else {
+        // If the editor has focus, ensure edit mode.
         this.mode = 'edit';
       }
+      this.activeCellIndex = index;
     } else {
       // No cell has focus, ensure command mode.
       this.mode = 'command';
     }
-    if (this.mode === 'command' && target !== this.node) {
-      delete this.node.dataset[CODE_RUNNER];
-    } else {
-      this.node.dataset[CODE_RUNNER] = 'true';
-    }
   }
 
   /**