From 057a8f6f1b29325e382a51344db5e610ff5f0a7e Mon Sep 17 00:00:00 2001 From: Pete Blois Date: Mon, 9 Nov 2020 11:00:44 -0800 Subject: [PATCH] Incorporate shadowRoot in focus calculation. This adds a call to getRootNode to get either the Document or the ShadowRoot to use when calculating whether the textarea has focus. getRootNode is guarded for older browser compatibility (IE). --- src/browser/services/CoreBrowserService.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/browser/services/CoreBrowserService.ts b/src/browser/services/CoreBrowserService.ts index 985253d9..4eabc895 100644 --- a/src/browser/services/CoreBrowserService.ts +++ b/src/browser/services/CoreBrowserService.ts @@ -14,6 +14,7 @@ export class CoreBrowserService implements ICoreBrowserService { } public get isFocused(): boolean { - return document.activeElement === this._textarea && document.hasFocus(); + const docOrShadowRoot = this._textarea.getRootNode ? this._textarea.getRootNode() as Document | ShadowRoot : document; + return docOrShadowRoot.activeElement === this._textarea && document.hasFocus(); } }