Skip to content

fix(composer): avoid double-scaling mention mirror text under Android WebView textZoom - #473

Merged
SiddDevZ merged 1 commit into
DuskBotAI:devfrom
AmigaPrime:fix/android-mention-textarea-text-zoom
Dec 3, 2026
Merged

SiddDevZ merged 1 commit into
DuskBotAI:devfrom
AmigaPrime:fix/android-mention-textarea-text-zoom

Conversation

@AmigaPrime

Copy link
Copy Markdown

What and why

On Android WebView, WebSettings.setTextZoom scales font-size and line-height even when text-size-adjust: none and -webkit-text-size-adjust: none are set on .mention-editor-mirror. Because MentionTextarea copies getComputedStyle(input) onto the mirror, Android WebView applies the system text scale a second time to the mirror's words, pushing the drawn text off the textarea's caret.

  • Split font-size and line-height out of TEXT_LAYOUT into ZOOMED_TEXT_LAYOUT in src/components/MentionTextarea.tsx and sync them through syncZoomedLength. When the mirror's computed length drifts from the textarea's (outside a 0.05px tolerance), it scales the written inline value down in up to two passes so both elements render at the same computed metrics. Non-numeric values (such as line-height: normal) are copied verbatim, and subsequent syncs return early without rewriting when the computed metrics already match.
  • Listen for window dusk:text-scale events in MentionTextarea to re-run resize() (recomputing field height and mirror metrics when text scale changes) and remove the listener on unmount.
  • Add DOM regression tests in src/components/MentionTextarea.dom.test.ts covering WebView text-zoom compensation and the scroll fast path, non-numeric line-height fallback, and dusk:text-scale re-sync + unmount cleanup.

How it was checked

Based on upstream dev (8f86ab208), head branch fix/android-mention-textarea-text-zoom:

  • node scripts/typecheck.mjs (pnpm typecheck): passed.
  • tsc -p apps/mobile/tsconfig.json --noEmit (mobile typecheck): passed.
  • oxlint --deny-warnings . (pnpm lint): 0 warnings, 0 errors across 8,247 files.
  • node scripts/generate-locale.mjs --check (pnpm i18n:check): passed.
  • vite build: passed.
  • Focused Vitest suites:
    • src/components/MentionTextarea.dom.test.ts and src/components/MentionTextarea.test.ts: 2 files, 11 passed (including 3 new regression tests).
    • Composer, mention, text-scale, and guard suites (MentionTextarea*, MentionText, MentionColors, text-scale, Composer.phone, Composer.mentions, Composer.slash, Composer.ime, Composer.dictation, scripts/testing/file-size-ratchet.test.ts, src/locales/vocabulary.test.ts): 12 files, 70 passed.

The full repository pnpm test suite and on-device Android WebView verification were not run locally.

  • pnpm typecheck, pnpm lint and pnpm test pass
  • New behaviour has a test
  • No secrets, personal data or local paths in the diff or screenshots

@SiddDevZ
SiddDevZ merged commit d57240e into DuskBotAI:dev Dec 3, 2026
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.

2 participants