diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts index e4551a39cbe5b..edc8ccd4b8009 100644 --- a/src/vs/editor/browser/controller/mouseHandler.ts +++ b/src/vs/editor/browser/controller/mouseHandler.ts @@ -99,7 +99,10 @@ export class MouseHandler extends ViewEventHandler { if (!this._mouseLeaveMonitor) { this._mouseLeaveMonitor = dom.addDisposableListener(this.viewHelper.viewDomNode.ownerDocument, 'mousemove', (e) => { - if (!this.viewHelper.viewDomNode.contains(e.target as Node | null)) { + const viewRoot = this.viewHelper.viewDomNode.getRootNode() as ShadowRoot | Document; + const viewRootIsShadowRoot = viewRoot instanceof ShadowRoot; + + if (!this.viewHelper.viewDomNode.contains(e.composedPath()[0] as Node | null) && !viewRootIsShadowRoot) { // went outside the editor! this._onMouseLeave(new EditorMouseEvent(e, false, this.viewHelper.viewDomNode)); }