Skip to content

Commit

Permalink
improve handling of initial currentWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Jul 27, 2023
1 parent c591323 commit 4837114
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/labextension/src/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ export class KernelWidgetTracker {
});
}
}
this._currentWidget =
notebookTracker.currentWidget ?? consoleTracker?.currentWidget ?? null;
// handle an existing current widget in case the KernelWidgetTracker
// is created a bit later, or if there is already a Notebook widget available
// on page load like in Notebook 7.
if (labShell?.currentWidget && hasKernelSession(labShell?.currentWidget)) {
this._currentWidget = labShell.currentWidget;
} else {
this._currentWidget =
notebookTracker.currentWidget ?? consoleTracker?.currentWidget ?? null;
}
}

/**
Expand Down

0 comments on commit 4837114

Please sign in to comment.