Skip to content

Comments

Fix iPadOS text selection and keyboard appearance issues#296836

Open
rewyekha wants to merge 2 commits intomicrosoft:mainfrom
rewyekha:fix/ipadOS-text-selection-keyboard-261958
Open

Fix iPadOS text selection and keyboard appearance issues#296836
rewyekha wants to merge 2 commits intomicrosoft:mainfrom
rewyekha:fix/ipadOS-text-selection-keyboard-261958

Conversation

@rewyekha
Copy link

Summary

Fixes #261958

Issues Fixed:

  1. Text Selection Not Working - Double-tap on a word did not select it on iPadOS
  2. On-Screen Keyboard Issue - Keyboard did not appear when tapping in the editor

Changes Made:

src/vs/editor/browser/controller/pointerHandler.ts

PointerEventHandler.onTap():

  • Reordered operations: dispatch gesture before focusing textarea
  • This ensures double-tap word selection works correctly because mouseDownCount: event.tapCount properly triggers word selection when tapCount === 2

TouchHandler.onTap():

  • Replaced simple moveTo() call with full dispatchMouse() handling
  • Now properly passes mouseDownCount: event.tapCount to support double-tap word selection
  • Moved focusTextArea() to after gesture dispatch

Technical Details:

  1. Double-tap detection: The Gesture class in touch.ts tracks tap timing and sets tapCount = 2 for taps within 400ms of each other

  2. Word selection trigger: When mouseDownCount === 2 is passed to viewController.dispatchMouse(), it calls _wordSelect() which selects the word at the cursor position

  3. iOS keyboard requirement: iOS Safari only shows the virtual keyboard when .focus() is called as a direct result of user touch interaction - not from programmatic calls outside of touch handlers. By keeping the focus call within the touch event handler but after gesture dispatch, both word selection and keyboard appearance work correctly.

Testing:

  • Tested in development environment
  • Zero TypeScript compilation errors
  • No changes to existing tests required

Device/Browser affected:

  • iPadOS 18.x (Safari, Chrome)
  • Works fine on desktop browsers (unchanged behavior)

…61958)

- Fix double-tap word selection on iOS/iPadOS by dispatching gesture before
  focusing textarea in PointerEventHandler and TouchHandler
- Move focusTextArea() call after dispatchMouse() to ensure selection is
  processed before focus changes
- Update TouchHandler to use dispatchMouse() with tapCount for proper
  double-tap word selection support
- Fix keyboard not appearing by keeping focus call within touch event handler
  (iOS requires direct user interaction to show on-screen keyboard)
- Add missing newline at end of iPadShowKeyboard.css
Copilot AI review requested due to automatic review settings February 22, 2026 15:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes critical text selection and keyboard appearance issues on iPadOS by reordering touch event handling operations to properly support double-tap word selection and ensure the on-screen keyboard appears when tapping in the editor.

Changes:

  • Reordered focusTextArea() to occur after gesture dispatch in both PointerEventHandler.onTap() and TouchHandler.onTap() to fix keyboard appearance on iOS/iPadOS
  • Replaced simple moveTo() call with full dispatchMouse() in TouchHandler.onTap() to properly pass tapCount for double-tap word selection
  • Added trailing newline to iPadShowKeyboard.css (formatting fix)

Reviewed changes

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

File Description
src/vs/editor/browser/controller/pointerHandler.ts Reordered operations in both PointerEventHandler and TouchHandler to dispatch gestures before focusing textarea, enabling double-tap word selection and keyboard appearance on touch devices
src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.css Added missing newline at end of file (formatting fix)

@rewyekha
Copy link
Author

@microsoft-github-policy-service agree

Addresses code review feedback to eliminate duplication between
PointerEventHandler and TouchHandler.

- Moved _dispatchGesture method to MouseHandler base class
- Both PointerEventHandler and TouchHandler now use inherited method
- Removed NavigationCommandRevealType and MouseTargetType imports
  from pointerHandler.ts (now only needed in base class)
@rewyekha
Copy link
Author

Hi @aiday-mar, I've submitted this PR to fix issue #261958 (iPadOS text selection and keyboard issues). Would you be able to review it when you have a chance? Thank you!

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.

[iPadOS] Cannot select text in GitHub Codespaces editor (Safari/Chrome)

2 participants