Support stylus/pen text selection on Android tablets#320994
Open
DaniilBabanin wants to merge 1 commit into
Open
Support stylus/pen text selection on Android tablets#320994DaniilBabanin wants to merge 1 commit into
DaniilBabanin wants to merge 1 commit into
Conversation
platform.isMobile requires a Mobi token in the user agent, which Android tablets usually omit, so they fell back to TouchHandler and a stylus could only scroll. Widen the Android check so tablets get the pen-aware PointerEventHandler too, matching what iOS already does. Follow-up to microsoft#198578
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjusts device detection in the editor pointer handler to broaden when the PointerEventHandler path is used on Android.
Changes:
- Treat all Android devices as “phone” for pointer handling, instead of only Android mobile.
- Potentially alter the event-handling path selection when
BrowserFeatures.pointerEventsis available.
Comment on lines
+144
to
145
| const isPhone = platform.isIOS || platform.isAndroid; | ||
| if (isPhone && BrowserFeatures.pointerEvents) { |
Author
There was a problem hiding this comment.
Including Android tablets is the intent of this PR — on tablets the TouchEvent fallback means a stylus can only scroll, never select text (see the PR description). Two points on the suggested alternatives:
- The condition is already gated by actual pointer capabilities: the handler is only chosen when
BrowserFeatures.pointerEventsis true, otherwise theTouchEvent/mouse fallbacks apply as before. - There is precedent for tablets on this path:
platform.isIOSalready routes iPads throughPointerEventHandler, where finger scrolling and pen selection coexist fine. This change just gives Android tablets the same treatment, and it behaves the same way in testing on a Samsung tablet with an S Pen (pen selects, finger scrolls, mouse unchanged — details in Support stylus/pen text selection on Android coder/code-server#7841).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This lets a stylus/pen drag select text in the editor on Android tablets, the same as it already does on iOS and Android phones. A finger drag still scrolls and the mouse is unchanged.
Problem
#198578 added the pen/stylus selection path (
PointerEventHandler) for mobile devices, gated by:platform.isMobilelooks for aMobitoken in the user agent, and Android tablets generally omit it. So on a tablet the editor falls back toTouchHandler, where pen input behaves like a finger: it can scroll but never select text.Change
Drop the
platform.isMobilerequirement for Android, so any Android device with Pointer Events support getsPointerEventHandler. The iOS branch is untouched, and Android phones already satisfied the old condition, so behavior only changes for Android tablets.Testing
This change was first made as a patch in code-server (coder/code-server#7841), where I built and tested it on a Samsung tablet with an S Pen in Chrome:
It is also reproducible in desktop Chrome with DevTools device mode set to an Android tablet user agent without a
Mobitoken. The code-server maintainers asked that the fix be submitted upstream rather than maintained as a patch, hence this PR.