Skip to content

Fix element picker with mobile emulation - #332183

Merged
Kyle Cutler (kycutler) merged 7 commits into
microsoft:mainfrom
YOSHII-Hiroto:fix/browser-element-picker-mobile-hover
Nov 10, 2026
Merged

Kyle Cutler (kycutler) merged 7 commits into
microsoft:mainfrom
YOSHII-Hiroto:fix/browser-element-picker-mobile-hover

Conversation

@YOSHII-Hiroto

@YOSHII-Hiroto 吉井 啓人(YOSHII, Hiroto) (YOSHII-Hiroto) commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

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

  • temporarily stop mouse-to-touch conversion while element selection is active, so regular mouse events reach the picker and the page
  • keep touch capability, the emulated viewport, and (pointer: coarse) active
  • keep the regular cursor for accurate element selection
  • restore mouse-to-touch conversion when element selection stops
  • reapply the conversion state when Mobile Emulation changes while selection is active

Scope 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: passed
  • npm run typecheck-client: passed
  • git diff --check: passed
  • manually verified on the previous revision (the picker input path is unchanged by removing the hover-event suppression):
    • hover highlighting and rectangle selection under Mobile Emulation
    • Desktop to Mobile and Mobile to Desktop transitions while the picker remains active
    • mouse-to-touch conversion resumes after the picker stops

Reproduction Before the Fix

With Mobile Emulation enabled, the circular touch cursor moves, but the element highlight does not follow the pointer.

Mobile Emulation before the fix
@YOSHII-Hiroto

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 _onPointerDown has 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 _dragStart is 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.

@YOSHII-Hiroto
吉井 啓人(YOSHII, Hiroto) (YOSHII-Hiroto) marked this pull request as ready for review August 23, 2026 17:36
@vs-code-engineering

vs-code-engineering Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Joaquín Ruales (@jruales)

Matched files:

  • src/vs/platform/browserView/electron-main/browserViewEmulator.ts
  • src/vs/platform/browserView/electron-main/browserViewInspector.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

@kycutler Kyle Cutler (kycutler) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@YOSHII-Hiroto

Copy link
Copy Markdown
Contributor Author

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.

@YOSHII-Hiroto

Copy link
Copy Markdown
Contributor Author

Kyle Cutler (@kycutler)
For context, I mentioned in #335192 that this PR may help with element highlighting and selection in Mobile Emulation. (Unifying Mobile Emulation with DevTools’ device toolbar, and changing the console or menu behavior, are outside this PR’s scope.)

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?

@kycutler

Copy link
Copy Markdown
Collaborator

吉井 啓人(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>
@YOSHII-Hiroto

Copy link
Copy Markdown
Contributor Author

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.

@kycutler Kyle Cutler (kycutler) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kycutler
Kyle Cutler (kycutler) enabled auto-merge (squash) November 10, 2026 17:18
@kycutler
Kyle Cutler (kycutler) merged commit cf1e601 into microsoft:main Nov 10, 2026
52 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

6 participants