From 18d44051cd7d0b15097c6c9afd9af16add88f56c Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Tue, 12 Jul 2022 17:01:20 -0700 Subject: [PATCH] Fix #151981. Avoid re-focus output when output already has focus. (#154991) --- .../notebook/browser/view/renderers/webviewPreloads.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.ts index 0ce36982b2492..f0eb46d08bbd0 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.ts @@ -400,6 +400,10 @@ async function webviewPreloads(ctx: PreloadContext) { function focusFirstFocusableInCell(cellId: string) { const cellOutputContainer = document.getElementById(cellId); if (cellOutputContainer) { + if (cellOutputContainer.contains(document.activeElement)) { + return; + } + const focusableElement = cellOutputContainer.querySelector('[tabindex="0"], [href], button, input, option, select, textarea') as HTMLElement | null; focusableElement?.focus(); }