Skip to content

feat: update overlay on pointerdown so inspector works in DevTools Device Mode#1

Open
MrDoomBringer wants to merge 1 commit into
ivanstnsk:mainfrom
MrDoomBringer:feat/update-overlay-on-pointerdown
Open

feat: update overlay on pointerdown so inspector works in DevTools Device Mode#1
MrDoomBringer wants to merge 1 commit into
ivanstnsk:mainfrom
MrDoomBringer:feat/update-overlay-on-pointerdown

Conversation

@MrDoomBringer
Copy link
Copy Markdown

Chrome DevTools device mode doesn't fire mousemove. Makes seeing which element you've selected kind of a pain.

No-op on desktop: inspectTarget() already dedups against the current target, so the pointerdown call after a hover-driven update returns immediately without re-rendering. Pointer events are universal across mouse and touch, so this also supports real touch devices, not just the DevTools emulator.

Have been working with this change patched for a few days now and found it helpful for working on mobile sites.

Thanks for your work on this @ivanstnsk :) React 19's _debugSource change breaking other component-click packages brought me here.

…bile emulation

The hover/overlay tracking effect previously only listened to `mousemove`,
plus a rAF loop reading `document.elementFromPoint(mouseX, mouseY)`. In
environments that don't fire `mousemove` — most notably Chrome DevTools
device-mode (touch emulation) — `mouseX/mouseY` stay at their initial
(0, 0) values, so `elementFromPoint` keeps returning the top-left element
(usually <body> / <html>), which the inspector treats as "hide overlay".
End result: tapping an element in mobile emulation never shows the
bounding box, even though the click-to-source XHR still fires correctly.

Adding a `pointerdown` listener (capture phase, so the click-blocker in
the other effect doesn't stop propagation before we run) updates the
overlay before the click handler opens the editor. After the first
pointer down, `mouseX/Y` are correct, so the rAF loop continues working
naturally.

No-op on desktop: `inspectTarget()` already dedups against the current
target, so the pointerdown call after a hover-driven update returns
immediately without re-rendering. Pointer events are universal across
mouse and touch, so this also supports real touch devices, not just
the DevTools emulator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant