Skip to content

[web] Stop iOS auto-zoom by sizing semantic inputs at 16px - #192328

Merged
auto-submit[bot] merged 5 commits into
flutter:masterfrom
flutter-zl:issue_192327_fix
Sep 10, 2026
Merged

auto-submit[bot] merged 5 commits into
flutter:masterfrom
flutter-zl:issue_192327_fix

Conversation

@flutter-zl

@flutter-zl flutter-zl commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #192327 and #129233.

Problem

  1. The semantic <input> and <textarea> never get a font size, so they fall back to the browser default, 11px on iOS. iOS auto-zooms any focused editable element under 16px, so tapping a TextField zoomed the page to 1.45x and left it there.

  2. The framework's own text style never reached the element either. It arrives before the element is attached, so it is stored, and activate() replayed it before enabling the strategy, which made updateElementStyle skip writing it.
    Font size, family, weight and spacing were all dropped. That is ensureSemantics() makes TextField font related properties in dev tools empty #129233.

Fix

Set the size on the element itself, to max(frameworkFontSize, 16) on iOS, at element creation and after every style sync. It cannot live in the global stylesheet because a later style update writes the framework font as an inline
font shorthand, which outranks any stylesheet rule. It assigns rather than only raises because on the first-focus path that shorthand is skipped and nothing else sets a size, so raising alone would leave a 24px field at 16px.

Nothing visible changes: the semantics tree is painted at filter: opacity(0%). Guarded by isIosSafari; Android was device-tested and does not auto-zoom.

Demo

Before https://flutter-demo-50-before.web.app
After https://flutter-demo-50-after.web.app

iOS auto-zoom. On an iPhone with semantics enabled, tap the 12px field. A default Material field is already 16px and cannot trigger the bug. Before, vvScale jumps to 1.45 and stays until you pinch out. After, it stays 1.00.

#129233. In desktop Chrome, click into the 24px field, then run:

[...document.querySelectorAll('flt-semantics-host input, flt-semantics-host textarea')]
  .map((e, i) => `${i} inline=${e.style.fontSize || 'NONE'} computed=${getComputedStyle(e).fontSize}`)
  .join('\n')

Index 3 is the 24px field. Before: inline=NONE computed=13.3333px. After: inline=24px computed=24px. Only the focused field carries a style, so the others correctly report NONE.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 5, 2026
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team labels Sep 5, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds a CSS rule to set the font size of semantic inputs and textareas to 16px on iOS Safari, preventing the browser from auto-zooming upon focus, and introduces corresponding unit tests. Feedback suggests adding explicit newlines to the generated CSS string for better readability in DevTools, and moving the cleanup of the temporary style element in the test to a finally block to prevent resource leaks in case of assertion failures.

Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/view_embedder/style_manager.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/test/engine/global_styles_test.dart Outdated
@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) labels Sep 8, 2026
/// Because style is supplied by the "flutter/textinput" channel and the DOM
/// element is supplied by the semantics tree, the existence of both at the
/// same time is not guaranteed.
void _syncStyle() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

_syncStyle is called in activate before super.enable(...) which means the style won't be applied.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Upated.

This also fixes #129233. On desktop Chrome, a focused 24px field now reports inline=24px, previously NONE.

Comment on lines +48 to +51
final double effectiveFontSize =
frameworkFontSize == null || frameworkFontSize < _iosMinimumEditableFontSize
? _iosMinimumEditableFontSize
: frameworkFontSize;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor suggestion:

Suggested change
final double effectiveFontSize =
frameworkFontSize == null || frameworkFontSize < _iosMinimumEditableFontSize
? _iosMinimumEditableFontSize
: frameworkFontSize;
final double effectiveFontSize = math.max(
_iosMinimumEditableFontSize,
frameworkFontSize ?? 0.0,
);

Comment on lines +1024 to +1026
debugEmulateIosSafari = false;
semantics().semanticsEnabled = false;
domDocument.activeElement?.blur();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's make sure the text editing state is properly cleaned up:

Suggested change
debugEmulateIosSafari = false;
semantics().semanticsEnabled = false;
domDocument.activeElement?.blur();
if (strategy.isEnabled) {
strategy.disable();
}
cleanForms();
debugEmulateIosSafari = false;
semantics().semanticsEnabled = false;
domDocument.activeElement?.blur();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

// This is the enabled path, where the shorthand really is written. The
// value persists past blur, so without the floor a later refocus would
// zoom.
expect(textField.editableElement.style.fontSize, '16px');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we make sure that other styles are also applied?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@flutter-zl
flutter-zl requested a review from mdebbar September 9, 2026 22:03

@mdebbar mdebbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@flutter-zl flutter-zl added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 10, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 10, 2026
Merged via the queue into flutter:master with commit 0414680 Sep 10, 2026
24 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 10, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 12, 2026
Roll Flutter from 63b9518f16bc to 2553f89be1ef (62 revisions)

flutter/flutter@63b9518...2553f89

2026-09-12 [email protected] Roll clang to 07d67299a15ce03b053736e2d31a668ee0576987 (flutter/flutter#192607)
2026-09-12 [email protected] Roll Dart SDK from b24b352c29db to 7863887acbfb (3 revisions) (flutter/flutter#192665)
2026-09-12 [email protected] fix(tree): et format --all (flutter/flutter#192669)
2026-09-12 [email protected] Support activity-alias in Android launcher activity detection (flutter/flutter#187251)
2026-09-12 [email protected] fix: regenerate gradle lockfiles for external_textures integration test (flutter/flutter#192657)
2026-09-12 [email protected] Roll Skia from 51aa02b2c195 to e5e96533b732 (4 revisions) (flutter/flutter#192646)
2026-09-12 [email protected] [WebParagraph] Fix text pixelation, glyph clipping, and snapping offsets to avoid subpixel raster caching (flutter/flutter#191736)
2026-09-12 [email protected] fix(tests): Add ruby dep to Mac windowing_test (flutter/flutter#192656)
2026-09-12 [email protected] Remove some `unawaited_futures` outdated ignores (flutter/flutter#192026)
2026-09-11 [email protected] Bump Dart to 3.13, reformat, re-enable formatting check (flutter/flutter#192649)
2026-09-11 [email protected] [android] Isolate API-34 high contrast listener in AccessibilityBridge behind Api34Impl (flutter/flutter#192502)
2026-09-11 [email protected] Update style guide for Dart 3.13 (flutter/flutter#192639)
2026-09-11 [email protected] ci(bringups): remove bringup from these tests (flutter/flutter#192637)
2026-09-11 [email protected] Unmark new_gallery_windows_impeller__transition_perf as bringup (flutter/flutter#192633)
2026-09-11 [email protected] Unmark new_gallery_windows_skia__transition_perf as bringup (flutter/flutter#192635)
2026-09-11 [email protected] Roll Skia from f446aec4ce9e to 51aa02b2c195 (2 revisions) (flutter/flutter#192631)
2026-09-11 [email protected] fix(ci): mac verify binaries still racing (flutter/flutter#192634)
2026-09-11 [email protected] Roll Packages from 8a35b16 to 9caa77c (8 revisions) (flutter/flutter#192630)
2026-09-11 [email protected] Roll Dart SDK from a76fee2722e0 to b24b352c29db (2 revisions) (flutter/flutter#192627)
2026-09-11 [email protected] [tool] Migrate PackagesCommand and Pub to modular dependency injection (flutter/flutter#192460)
2026-09-11 [email protected] [tool] Migrate Darwin framework commands to modular dependency injection (flutter/flutter#192252)
2026-09-11 [email protected] [tool] Migrate Upgrade, Downgrade, and UpdatePackages commands to modular dependency injection (flutter/flutter#190787)
2026-09-11 [email protected] Roll Skia from b3fa80a0e168 to f446aec4ce9e (55 revisions) (flutter/flutter#192620)
2026-09-11 [email protected] Roll Dart SDK from d20d59cfa664 to a76fee2722e0 (2 revisions) (flutter/flutter#192616)
2026-09-11 [email protected] remove deeplink integration tests from bringup (flutter/flutter#192459)
2026-09-11 [email protected] Revert: [devicelab] Clean up Chrome profile directories and trap abort signals in web benchmarks (flutter/flutter#192615)
2026-09-11 [email protected] Roll Fuchsia Linux SDK from C0j8F-_Iy-OQZ6YyI... to m69nfK-wnHaMTe8P9... (flutter/flutter#192608)
2026-09-11 [email protected] Fix Wasm build cache mismatch in ResidentWebRunner and browser 404 fallbacks (flutter/flutter#190786)
2026-09-11 [email protected] Roll Dart SDK from 3ce3116bc9ec to d20d59cfa664 (1 revision) (flutter/flutter#192588)
2026-09-11 [email protected] [Linux] Keep the frame at the top of a resizing subsurface (flutter/flutter#192408)
2026-09-10 [email protected] [devicelab] Clean up Chrome profile directories and trap abort signals in web benchmarks (flutter/flutter#192584)
2026-09-10 [email protected] [web] Keep ImageSource alive until Picture disposal (flutter/flutter#192516)
2026-09-10 [email protected] Remove the accessibility evaluations feature flag (flutter/flutter#192266)
2026-09-10 [email protected] Promote Windows gradient benchmark tests to non-bringup (flutter/flutter#192581)
2026-09-10 [email protected] Remove commented out export in `text_input.dart` since the dart compiler has the correct behavior now (flutter/flutter#191539)
2026-09-10 [email protected] [flutter_tools] Do not mistake server-initiated requests for responses to client requests in AnalysisServer (flutter/flutter#192546)
2026-09-10 [email protected] Roll Packages from 36e088a to 8a35b16 (12 revisions) (flutter/flutter#192550)
2026-09-10 [email protected] Roll pub packages (flutter/flutter#192517)
2026-09-10 [email protected] feat(web): support --web-content-hash for entrypoint files (flutter/flutter#190153)
2026-09-10 [email protected] [web] Stop iOS auto-zoom by sizing semantic inputs at 16px (flutter/flutter#192328)
2026-09-10 [email protected] Roll Dart SDK from 0d55b7a6a9ee to 3ce3116bc9ec (2 revisions) (flutter/flutter#192534)
2026-09-10 [email protected] Update more enum instances comparison to use equality == since dart has the correct behavior now (flutter/flutter#191788)
2026-09-10 [email protected] Fix specify_nonobvious_local_variable_types lints in luci_resultdb_test.dart (flutter/flutter#192543)
2026-09-10 [email protected] Roll ICU from 8cc91d9b6ab9 to 6ebb40c59477 (1 revision) (flutter/flutter#192527)
2026-09-10 [email protected] [Linux] Make the framebuffer depth/stencil buffer optional (flutter/flutter#192156)
2026-09-10 [email protected] [Linux] Cancel input when events stop being delivered (flutter/flutter#192277)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: text input Entering text in a text field or keyboard related problems CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web] iOS Safari auto-zooms the page to 1.45x when a TextField is tapped with semantics enabled

2 participants