From 2cbdd9e646185086c35e1cb8c4929c6c5b4c0dae Mon Sep 17 00:00:00 2001 From: Nick Strayer Date: Fri, 20 Dec 2024 11:10:31 -0500 Subject: [PATCH] Add comment explaining why we use just the root of a ref in claiming and releasing the webview --- .../browser/notebookCells/hooks/useWebviewMount.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/vs/workbench/contrib/positronNotebook/browser/notebookCells/hooks/useWebviewMount.ts b/src/vs/workbench/contrib/positronNotebook/browser/notebookCells/hooks/useWebviewMount.ts index 146281e3a6f..be041c85c4f 100644 --- a/src/vs/workbench/contrib/positronNotebook/browser/notebookCells/hooks/useWebviewMount.ts +++ b/src/vs/workbench/contrib/positronNotebook/browser/notebookCells/hooks/useWebviewMount.ts @@ -132,6 +132,9 @@ export function useWebviewMount(webview: Promise) { return; } try { + // We're using the base ref here because it's a constant reference and thus + // will avoid unnecessary mismatches for claiming and releasing the webview + // across multiple renders. webviewElement.claim(containerRef, getWindow(containerRef.current), undefined); } catch (err) { setError(new WebviewMountError('Failed to claim webview', err instanceof Error ? err : undefined));