Repository navigation
Fix element picker with mobile emulation - #332183
Kyle Cutler (kycutler) merged 7 commits into
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Fixes element picking during mobile emulation while preserving mobile presentation and restoring touch conversion afterward.
Changes:
- Temporarily disables mouse-to-touch conversion during element selection.
- Adds a simulated mobile touch cursor.
- Synchronizes picker state with device emulation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
browserViewEmulator.ts |
Adjusts touch-event conversion during selection. |
browserView.ts |
Connects inspector and emulator state. |
preload-browserView.ts |
Adds and manages the simulated touch cursor. |
Suppressed comments (2)
src/vs/platform/browserView/electron-browser/preload-browserView.ts:855
- This redisplays the touch circle on the first move after
_onPointerDownhas switched the page cursor to a crosshair. During a drag, both cursors are therefore visible. Keep updating the circle coordinates, but leave it hidden while_dragStartis set so the crosshair remains the sole drag cursor.
if (this._showTouchCursor) {
this._touchCursor.style.display = 'block';
this._touchCursor.style.left = `${e.clientX}px`;
this._touchCursor.style.top = `${e.clientY}px`;
}
src/vs/platform/browserView/electron-browser/preload-browserView.ts:855
- The custom circle is shown even when the event is over the picker's shadow UI. The document-level
* { cursor: none }rule cannot select shadow descendants, and controls in this shadow root explicitly use native cursors, so comment buttons display both the native pointer and this circle. Apply the touch cursor mode inside the shadow root or suppress the circle where a native picker cursor is shown.
this._touchCursor.style.display = 'block';
this._touchCursor.style.left = `${e.clientX}px`;
this._touchCursor.style.top = `${e.clientY}px`;
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Joaquín Ruales (@jruales)Matched files:
|
ce28151 to
9b2fd15
Compare
Kyle Cutler (kycutler)
left a comment
There was a problem hiding this comment.
The changes look great overall, thanks 吉井 啓人(YOSHII, Hiroto) (@YOSHII-Hiroto)! Only feedback is to remove the emulated touch cursor but otherwise this should be good to merge.
|
Kyle Cutler (@kycutler) Thank you for the review. I have removed the emulated touch cursor and kept the regular cursor as requested. I also ensured that enabling the picker under Mobile Emulation does not change the events delivered to the page, including after drag release and picker shutdown. The updated implementation and verification details are in f56f785. I have resolved the review thread and would appreciate another look when you have a chance. |
|
Kyle Cutler (@kycutler) On the hover-event suppression: the picker still receives the pointer events it needs for selection; the suppression is intended to prevent the additional hover events from reaching the page. Does that clarify the intent, or would you recommend a different approach? |
|
吉井 啓人(YOSHII, Hiroto) (@YOSHII-Hiroto) apologies for the lack of response, and thanks for your patience. I think it would be best to keep it simple: turn off mouse-to-touch conversion while element selection is active (as you already do in _applyTouchAndMedia) and just let regular mouse events through to the page. I think it's reasonable for the page to see mouse events while selecting. Could you remove the hover-event suppression, i.e. _onEmulationHoverEvent, setPageMouseEventsSuppressed, the setElementPickerPageMouseEventsSuppressed IPC, and the related emulator/inspector plumbing? Then I'm happy to approve. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Kyle Cutler (@kycutler) Thank you for your guidance. I have removed the hover-event suppression and the related IPC and emulator/inspector plumbing in 31cf36d. Mouse-to-touch conversion remains disabled while element selection is active, so regular mouse events can reach the page. To make this explicit, this behavior is not compatible with Chromium DevTools, where using the element picker with touch emulation enabled does not dispatch mouse input events to the page, but I will defer to your approach here. I would appreciate another look when you have a chance. |
Kyle Cutler (kycutler)
left a comment
There was a problem hiding this comment.
Looks good, thank you 吉井 啓人(YOSHII, Hiroto) (@YOSHII-Hiroto)!
Summary
Fix element picking under Mobile Emulation while preserving the emulated mobile presentation.
Fixes #332182
Root Cause
Mobile Emulation converts mouse input into touch input. Before contact begins, this conversion suppresses the pointer movement events that the element picker uses for hover highlighting.
Disabling Mobile Emulation is not a suitable workaround because it can change the responsive layout and the element being inspected.
Implementation
(pointer: coarse)activeScope and Risk
The behavior change is limited to the Integrated Browser's Mobile Emulation and element picker. While selection is active under Mobile Emulation, the page receives regular mouse events instead of touch events. Normal Mobile Emulation continues converting mouse input into touch input before selection starts and after it stops. Desktop input behavior remains unchanged.
Testing
npm run eslint -- src/vs/platform/browserView/electron-browser/preload-browserView.ts src/vs/platform/browserView/electron-main/browserView.ts src/vs/platform/browserView/electron-main/browserViewEmulator.ts src/vs/platform/browserView/electron-main/browserViewFrameInspector.ts src/vs/platform/browserView/electron-main/browserViewInspector.ts: passednpm run typecheck-client: passedgit diff --check: passedReproduction Before the Fix
With Mobile Emulation enabled, the circular touch cursor moves, but the element highlight does not follow the pointer.