Browse Source

Scroll cell into view after output collapse (#10491)

* Scroll cell into view after output collapse

* Package integrity updates
Daria Vasyukova 3 years ago
parent
commit
880c913175
2 changed files with 9 additions and 0 deletions
  1. 1 0
      packages/cells/package.json
  2. 8 0
      packages/cells/src/collapser.tsx

+ 1 - 0
packages/cells/package.json

@@ -58,6 +58,7 @@
     "@jupyterlab/ui-components": "^3.1.0-beta.0",
     "@lumino/algorithm": "^1.3.3",
     "@lumino/coreutils": "^1.5.3",
+    "@lumino/domutils": "^1.2.3",
     "@lumino/dragdrop": "^1.7.1",
     "@lumino/messaging": "^1.4.3",
     "@lumino/signaling": "^1.4.3",

+ 8 - 0
packages/cells/src/collapser.tsx

@@ -4,6 +4,7 @@
 |----------------------------------------------------------------------------*/
 
 import { ReactWidget } from '@jupyterlab/apputils';
+import { ElementExt } from '@lumino/domutils';
 
 import * as React from 'react';
 
@@ -135,6 +136,13 @@ export class OutputCollapser extends Collapser {
     const cell = this.parent?.parent as CodeCell | undefined | null;
     if (cell) {
       cell.outputHidden = !cell.outputHidden;
+      /* Scroll cell into view after output collapse */
+      if (cell.outputHidden) {
+        let area = cell.parent?.node;
+        if (area) {
+          ElementExt.scrollIntoViewIfNeeded(area, cell.node);
+        }
+      }
     }
     /* We need this until we watch the cell state */
     this.update();