From eb7631ccc5cd3f0bdb46ded5815624cc241f4964 Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Sat, 31 Oct 2026 00:45:04 +0000 Subject: [PATCH] fix(mobile): keep Markdown editor selection visible deep in long files (#36505) * fix(mobile): keep Markdown editor selection visible deep in long files iOS WebKit stopped drawing the selection highlight and handles about two screens into the rich Markdown editor because the editable element was scrolled by its non-editable host. Make the editable element scroll itself. * test(mobile): find the editor's document rule by a property it still has --- mobile/src/components/rich-markdown/document-style.ts | 7 ++++--- .../src/components/rich-markdown/page-stylesheet.test.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mobile/src/components/rich-markdown/document-style.ts b/mobile/src/components/rich-markdown/document-style.ts index 06b3bd93509..c7f1f443b39 100644 --- a/mobile/src/components/rich-markdown/document-style.ts +++ b/mobile/src/components/rich-markdown/document-style.ts @@ -2,6 +2,7 @@ import { colors, getMobileColorScheme } from '../../theme/mobile-theme' import { TEXT_INPUT_FONT_SIZE } from '../../platform/text-input-font-size' // Read theme at build time; native embeds sheet, page scopes it to editor host. +// #editor scrolls itself: iOS WebKit stops drawing selection ~2 screens into an editable scrolled by a separate box (#34472). // Bind size to text-input seam: native body size, web>=16px floor prevents iOS focus zoom that keyboard seam mistakes for no keyboard; one binding keeps both hosts aligned. export function richMarkdownEditorStyle(): string { return ` :root { @@ -26,11 +27,11 @@ export function richMarkdownEditorStyle(): string { background: var(--editor-surface); color: var(--foreground); font-family: var(--font-sans); - overscroll-behavior: contain; } - body { overflow: auto; } #editor { - min-height: 100vh; + height: 100%; + overflow: auto; + overscroll-behavior: contain; padding: 18px 16px 112px; outline: none; font-size: ${TEXT_INPUT_FONT_SIZE}px; diff --git a/mobile/src/components/rich-markdown/page-stylesheet.test.ts b/mobile/src/components/rich-markdown/page-stylesheet.test.ts index e19f00b1a2d..60d29f1bdb0 100644 --- a/mobile/src/components/rich-markdown/page-stylesheet.test.ts +++ b/mobile/src/components/rich-markdown/page-stylesheet.test.ts @@ -20,7 +20,7 @@ describe('the editor stylesheet on the page', () => { expect(scoped).toContain('--foreground:') const rootRules = scoped .split('}') - .filter((rule) => rule.includes('--foreground:') || rule.includes('overscroll-behavior:')) + .filter((rule) => rule.includes('--foreground:') || rule.includes('min-height: 100%')) expect(rootRules.length).toBeGreaterThan(0) for (const rule of rootRules) { expect(rule.trimStart().startsWith(PREFIX)).toBe(true)