Skip to content

Commit 98c3817

Browse files
authored
prevent mobile viewport auto-zoom on input focus (#5152)
Mobile WebKit/Blink engines (such as Safari and Chrome on iOS) automatically zoom in the entire page viewport when a text or numeric input is focused if the computed font-size is strictly less than 16px. This page-level zoom remains locked even after the input is blurred, disrupting the layout and forcing users to manually pinch-to-zoom out to return to normal dimensions. This change fixes the issue globally for the documentation examples and provides educational guidelines for developers copying the patterns: 1. Systemic Styles Guard: Added a scoped style rule in examples.css setting 'font-size: 16px' for all inputs and selects inside floating '.controls' containers. This covers active widgets (e.g. Model Transformations, Post-Processing, variant swapping) across almost all example pages without impacting other standard utility forms. 2. Developer Guidance Tip: Appended an educational "Mobile WebUX Tip" callout under the Model Transformations demo text block inside scenegraph/index.html, explaining the 16px browser threshold quirk to developers who copy-paste the custom markup blocks for their own standalone applications. Verified layout presentation and viewport locking (locked at stable 1.0x scale) under small-screen interaction models. Playwright test suite passes cleanly.
1 parent 56d00bc commit 98c3817

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

packages/modelviewer.dev/examples/scenegraph/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ <h2 class="demo-title">Model Transformations</h2>
156156
<code>ios-src</code> is not specified, since in this case a USDZ
157157
will be generated on the fly from the current state.
158158
</p>
159+
<p><b>Tip:</b> When building custom interactive overlay controls with text or numeric input fields on mobile, ensure your inputs are styled with a CSS rule setting <code>font-size: 16px;</code> (or larger). If a focused text field's computed font size is below 16px, mobile WebKit browsers (like iOS Safari and Chrome) will automatically zoom in the entire viewport, which does not automatically reset when the input is blurred and can break the page layout.</p>
159160
</div>
160161
<example-snippet stamp-to="transforms" highlight-as="html">
161162
<template>

packages/modelviewer.dev/styles/examples.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,4 +1049,10 @@ paper-button {
10491049
width: var(--og-sidebar-width);
10501050
box-shadow: 2px 0 4px rgba(0,0,0,0.1);
10511051
}
1052+
}
1053+
1054+
/* Prevent iOS mobile auto-viewport zoom on user interactions with input/select controls */
1055+
.controls input,
1056+
.controls select {
1057+
font-size: 16px;
10521058
}

0 commit comments

Comments
 (0)