From 200403c023b9949b372dafefb7803b77ade83d24 Mon Sep 17 00:00:00 2001 From: rebornix Date: Tue, 12 Jul 2022 13:51:54 -0700 Subject: [PATCH] Fix #151981. Avoid re-focus output when output already has focus. --- .../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(); }