Skip to content

Commit 9cb2879

Browse files
committed
Dashboard: allow pinch-to-zoom by dropping maximum-scale on dashboard sections
Scope maximum-scale removal to dashboard sections via a new Head allowZoom prop; other surfaces keep maximum-scale=1.
1 parent 804b08a commit 9cb2879

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

client/components/head/index.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@ const Head = ( {
88
branchName,
99
faviconUrl,
1010
shouldPrefetchRestProxy = true,
11+
allowZoom = false,
1112
} ) => {
1213
return (
1314
<head>
1415
<title>{ title }</title>
1516

1617
<meta charSet="utf-8" />
1718
<meta httpEquiv="X-UA-Compatible" content="IE=Edge" />
18-
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
19+
<meta
20+
name="viewport"
21+
content={
22+
allowZoom
23+
? 'width=device-width, initial-scale=1'
24+
: 'width=device-width, initial-scale=1, maximum-scale=1'
25+
}
26+
/>
1927
<meta name="format-detection" content="telephone=no" />
2028
<meta name="mobile-web-app-capable" content="yes" />
2129
<meta name="apple-mobile-web-app-capable" content="yes" />
@@ -53,6 +61,7 @@ Head.propTypes = {
5361
branchName: PropTypes.string,
5462
faviconUrl: PropTypes.string,
5563
shouldPrefetchRestProxy: PropTypes.bool,
64+
allowZoom: PropTypes.bool,
5665
};
5766

5867
export default Head;

client/components/head/test/index.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,18 @@ describe( 'Head', () => {
3535
document.querySelector( `link[rel="prefetch"][href="${ restProxyHref }"]` )
3636
).toBeNull();
3737
} );
38+
39+
test( 'should block zoom via maximum-scale by default', () => {
40+
render( <Head /> );
41+
expect( document.querySelector( 'meta[name="viewport"]' )?.getAttribute( 'content' ) ).toBe(
42+
'width=device-width, initial-scale=1, maximum-scale=1'
43+
);
44+
} );
45+
46+
test( 'should allow zoom by dropping maximum-scale when allowZoom is set', () => {
47+
render( <Head allowZoom /> );
48+
expect( document.querySelector( 'meta[name="viewport"]' )?.getAttribute( 'content' ) ).toBe(
49+
'width=device-width, initial-scale=1'
50+
);
51+
} );
3852
} );

client/document/index.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import WooCommerceLogo from 'calypso/components/woocommerce-logo';
2424
import { InterimOmnibar } from 'calypso/dashboard/app/interim-omnibar/interim-omnibar';
2525
import { InitialOmnibar } from 'calypso/dashboard/app/omnibar/omnibar';
2626
import { getDashboardStepperLogo } from 'calypso/dashboard/app/stepper-logo';
27+
import { A4A_DASHBOARD_SECTION_DEFINITION } from 'calypso/dashboard/app-a4a/section';
2728
import { CIAB_DASHBOARD_SECTION_DEFINITION } from 'calypso/dashboard/app-ciab/section';
2829
import { DOTCOM_DASHBOARD_SECTION_DEFINITION } from 'calypso/dashboard/app-dotcom/section';
2930
import isDashboardEnv from 'calypso/dashboard/utils/is-dashboard-env';
@@ -113,6 +114,11 @@ class Document extends Component {
113114
? `var localeFromRoute = ${ jsonStringifyForHtml( params.lang ?? '' ) };\n`
114115
: '' );
115116

117+
const isDashboardSection =
118+
sectionName === DOTCOM_DASHBOARD_SECTION_DEFINITION.name ||
119+
sectionName === CIAB_DASHBOARD_SECTION_DEFINITION.name ||
120+
sectionName === A4A_DASHBOARD_SECTION_DEFINITION.name;
121+
116122
const isDashboardOmnibarPage =
117123
( isDashboardEnv() || env === 'development' ) &&
118124
( sectionName === DOTCOM_DASHBOARD_SECTION_DEFINITION.name ||
@@ -153,6 +159,7 @@ class Document extends Component {
153159
branchName={ branchName }
154160
inlineScriptNonce={ inlineScriptNonce }
155161
faviconUrl={ headFaviconUrl }
162+
allowZoom={ isDashboardSection }
156163
// Firefox can reuse the anonymous REST proxy prefetch after login; see https://github.com/Automattic/wp-calypso/pull/111842.
157164
shouldPrefetchRestProxy={ ! app?.isFirefox }
158165
>

0 commit comments

Comments
 (0)