Skip to content

Commit

Permalink
Initial fix for node attachment issue with windowed notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Oct 25, 2023
1 parent 597580e commit 736f429
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/ExecuteTimeWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,20 @@ export default class ExecuteTimeWidget extends Widget {
await cell.ready;
const executionMetadata = cell.model.getMetadata('execution') as JSONObject;
if (executionMetadata && JSONExt.isObject(executionMetadata)) {
// Wait until the cell is in viewport before querying for the node,
// as otherwise it would not be found as contents are detached from DOM.
if (!cell.inViewport) {
// TODO: cancel the update if another update was scheduled since.
await new Promise<void>((resolved) => {
const handler = (_emitter: Cell<ICellModel>, attached: boolean) => {
if (attached) {
resolved();
cell.inViewportChanged.disconnect(handler);
}
};
cell.inViewportChanged.connect(handler);
});
}
let executionTimeNode: HTMLDivElement = cell.node.querySelector(
`.${EXECUTE_TIME_CLASS}`
);
Expand Down

0 comments on commit 736f429

Please sign in to comment.