From 5ff0a8faaf8fd1964967007ecf2ff31017f69f49 Mon Sep 17 00:00:00 2001 From: elias-coderunner <276592846+elias-coderunner@users.noreply.github.com> Date: Tue, 1 Dec 2026 10:14:57 +0000 Subject: [PATCH] Add on-demand on-screen keyboard for Monaco editor on touch devices Adds a quilt patch that ships a module (mobileOnDemandKeyboard.ts) which puts the editor in a read mode on touch devices by default, so taps don't summon the OS virtual keyboard. A double-tap inside the editor enters typing mode; tapping outside, or the browser reporting the keyboard dismissed, exits back to read mode. Fixes #8166 --- CHANGELOG.md | 9 + patches/mobile-on-demand-keyboard.diff | 336 ++++++++++++++++++++++++ patches/series | 1 + test/e2e/mobileOnDemandKeyboard.test.ts | 136 ++++++++++ 4 files changed, 482 insertions(+) create mode 100644 patches/mobile-on-demand-keyboard.diff create mode 100644 test/e2e/mobileOnDemandKeyboard.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index e3cf276ab19d..7abedd99e9dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,15 @@ Code v99.99.999 ## Unreleased +### Added + +- On-demand on-screen keyboard for the Monaco editor on touch devices. The + editor starts in a read mode where taps scroll and position the caret + without summoning the OS keyboard; a double-tap inside the editor opts + into typing mode, and a tap outside the editor (or the OS reporting the + keyboard dismissed) exits back to read mode. Makes code-server practical + to use as an actual editor on a phone instead of just as a viewer. + ## [4.146.0](https://github.com/coder/code-server/releases/tag/v4.146.0) - 2026-11-20 Code v1.146.0 diff --git a/patches/mobile-on-demand-keyboard.diff b/patches/mobile-on-demand-keyboard.diff new file mode 100644 index 000000000000..35cd00092e16 --- /dev/null +++ b/patches/mobile-on-demand-keyboard.diff @@ -0,0 +1,336 @@ +Add on-demand on-screen keyboard for the Monaco editor on touch devices + +Adds a small zero-dep module (mobileOnDemandKeyboard.ts) that suppresses +the OS virtual keyboard from popping up on a tap into the Monaco editor +and instead enters a read-only "view mode" by default on touch devices. +The user explicitly opts into typing mode with a double-tap inside the +editor; tapping outside the editor, or the browser/OS reporting the +on-screen keyboard dismissed, exits typing mode back to view mode. + +Suppression is enforced with three cooperating layers against Monaco's +focus path (both the legacy `textarea.inputarea` and the modern +`div.native-edit-context`): a `.focus()` method override on the input +prototypes, a capture-phase `focusin` blur guard, and `inputmode="none"` +stamping via synchronous setter hooks on `Element.prototype` plus a +MutationObserver safety net. The module is imported and invoked once +from the existing workbench.ts bundle entry, so no new