From eda8b6c7e3ec00c36c6e7d427c498f1dd0a95107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Wed, 2 Aug 2023 18:21:08 +0200 Subject: [PATCH] Backport PR #14865: In defer mode render enough cells to fill the viewport --- packages/notebook/src/widget.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/notebook/src/widget.ts b/packages/notebook/src/widget.ts index 7ca076bbc8cc..d04e2f103a41 100644 --- a/packages/notebook/src/widget.ts +++ b/packages/notebook/src/widget.ts @@ -887,8 +887,19 @@ export class StaticNotebook extends WindowedList { cellIdx++; } + // If the notebook is not fully rendered if (cellIdx < this.cellsArray.length) { - this._scheduleCellRenderOnIdle(); + // If we are defering the cell rendering and the rendered cells do + // not fill the viewport yet + if ( + this.notebookConfig.windowingMode === 'defer' && + this.viewportNode.clientHeight < this.node.clientHeight + ) { + // Spend more time rendering cells to fill the viewport + await this._runOnIdleTime(); + } else { + this._scheduleCellRenderOnIdle(); + } } else { if (this._idleCallBack) { window.cancelIdleCallback(this._idleCallBack);