Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.ts')
-rw-r--r--src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.ts b/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.ts
index 3f2df96e305..6cd5d2c242d 100644
--- a/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.ts
+++ b/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.ts
@@ -316,8 +316,17 @@ export class CodeCell extends Disposable {
}));
}
+ private shouldUpdateDOMFocus() {
+ // The DOM focus needs to be adjusted:
+ // when a cell editor should be focused
+ // the document active element is inside the notebook editor or the document body (cell editor being disposed previously)
+ return this.notebookEditor.getActiveCell() === this.viewCell
+ && this.viewCell.focusMode === CellFocusMode.Editor
+ && (this.notebookEditor.hasEditorFocus() || document.activeElement === document.body);
+ }
+
private updateEditorForFocusModeChange() {
- if (this.viewCell.focusMode === CellFocusMode.Editor && this.notebookEditor.getActiveCell() === this.viewCell) {
+ if (this.shouldUpdateDOMFocus()) {
this.templateData.editor?.focus();
}
@@ -479,7 +488,7 @@ export class CodeCell extends Disposable {
this._isDisposed = true;
// move focus back to the cell list otherwise the focus goes to body
- if (this.notebookEditor.getActiveCell() === this.viewCell && this.viewCell.focusMode === CellFocusMode.Editor) {
+ if (this.shouldUpdateDOMFocus()) {
this.notebookEditor.focusContainer();
}