From 02229abc3453f54fbd9ce0d47fa0d2cb9ecbe038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pauli=20Ojanper=C3=A4?= Date: Tue, 23 Jun 2026 12:34:31 +0000 Subject: [PATCH] fix(input): pierce shadow DOM in onTouchMove over-canvas detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit InputManager.onTouchMove used document.elementFromPoint() to decide whether a touch is over the canvas. When Phaser runs inside a shadow root, that call resolves to the shadow host rather than the canvas, so `overCanvas` is always false, `isOver` latches false, and every touchmove inside the shadow root is silently dropped — pointer.x/y never update on touch devices. Use the canvas's root node (canvas.getRootNode(), a ShadowRoot when inside shadow DOM, otherwise the Document) which exposes elementFromPoint and resolves the topmost element across the shadow boundary. Falls back to document when the root node has no elementFromPoint. --- src/input/InputManager.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/input/InputManager.js b/src/input/InputManager.js index d2cc52cda0..671fe3c93b 100644 --- a/src/input/InputManager.js +++ b/src/input/InputManager.js @@ -610,7 +610,12 @@ var InputManager = new Class({ if (pointer.active && pointer.identifier === changedTouch.identifier) { - var element = document.elementFromPoint(changedTouch.clientX, changedTouch.clientY); + // Use the canvas's root node (a ShadowRoot when Phaser runs inside shadow DOM, + // otherwise the Document) so over-canvas detection pierces shadow boundaries. + // document.elementFromPoint does not, returning the shadow host instead, which made + // isOver latch false and silently dropped every touch move inside a shadow root. + var inputRoot = this.canvas ? this.canvas.getRootNode() : null; + var element = (inputRoot && inputRoot.elementFromPoint ? inputRoot : document).elementFromPoint(changedTouch.clientX, changedTouch.clientY); var overCanvas = element === this.canvas; if (!this.isOver && overCanvas)