diff --git a/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts b/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts index 6849223732a847d64b03232825b51749b30c4ab7..4ae425ece2c2bc0e22ee41f79d4750835039dc66 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts @@ -66,9 +66,15 @@ export class NotebookCellList extends WorkbenchList implements ID }); this._previousFocusedElements = e.elements; - // Force focus out of webview if focus is in webview and I press an arrow key to focus the next cell - if (document.activeElement && document.activeElement.tagName.toLowerCase() === 'webview') { - this.focusView(); + // if focus is in the list, but is not inside the focused element, then reset focus + if (DOM.isAncestor(document.activeElement, this.rowsContainer)) { + const focusedElement = this.getFocusedElements()[0]; + if (focusedElement) { + const focusedDomElement = this.domElementOfElement(focusedElement); + if (focusedDomElement && !DOM.isAncestor(document.activeElement, focusedDomElement)) { + focusedDomElement.focus(); + } + } } }));