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
This commit is contained in:
Kelvin Amoaba
2026-10-31 00:45:04 +00:00
committed by GitHub
parent 76cf164cf9
commit eb7631ccc5
2 changed files with 5 additions and 4 deletions
@@ -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;
@@ -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)