Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion client/components/head/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ const Head = ( {
branchName,
faviconUrl,
shouldPrefetchRestProxy = true,
allowZoom = false,
} ) => {
return (
<head>
<title>{ title }</title>

<meta charSet="utf-8" />
<meta httpEquiv="X-UA-Compatible" content="IE=Edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta
name="viewport"
content={
allowZoom
? 'width=device-width, initial-scale=1'
: 'width=device-width, initial-scale=1, maximum-scale=1'
}
/>
<meta name="format-detection" content="telephone=no" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
Expand Down Expand Up @@ -53,6 +61,7 @@ Head.propTypes = {
branchName: PropTypes.string,
faviconUrl: PropTypes.string,
shouldPrefetchRestProxy: PropTypes.bool,
allowZoom: PropTypes.bool,
};

export default Head;
14 changes: 14 additions & 0 deletions client/components/head/test/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,18 @@ describe( 'Head', () => {
document.querySelector( `link[rel="prefetch"][href="${ restProxyHref }"]` )
).toBeNull();
} );

test( 'should block zoom via maximum-scale by default', () => {
render( <Head /> );
expect( document.querySelector( 'meta[name="viewport"]' )?.getAttribute( 'content' ) ).toBe(
'width=device-width, initial-scale=1, maximum-scale=1'
);
} );

test( 'should allow zoom by dropping maximum-scale when allowZoom is set', () => {
render( <Head allowZoom /> );
expect( document.querySelector( 'meta[name="viewport"]' )?.getAttribute( 'content' ) ).toBe(
'width=device-width, initial-scale=1'
);
} );
} );
7 changes: 7 additions & 0 deletions client/document/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import WooCommerceLogo from 'calypso/components/woocommerce-logo';
import { InterimOmnibar } from 'calypso/dashboard/app/interim-omnibar/interim-omnibar';
import { InitialOmnibar } from 'calypso/dashboard/app/omnibar/omnibar';
import { getDashboardStepperLogo } from 'calypso/dashboard/app/stepper-logo';
import { A4A_DASHBOARD_SECTION_DEFINITION } from 'calypso/dashboard/app-a4a/section';
import { CIAB_DASHBOARD_SECTION_DEFINITION } from 'calypso/dashboard/app-ciab/section';
import { DOTCOM_DASHBOARD_SECTION_DEFINITION } from 'calypso/dashboard/app-dotcom/section';
import isDashboardEnv from 'calypso/dashboard/utils/is-dashboard-env';
Expand Down Expand Up @@ -113,6 +114,11 @@ class Document extends Component {
? `var localeFromRoute = ${ jsonStringifyForHtml( params.lang ?? '' ) };\n`
: '' );

const isDashboardSection =
sectionName === DOTCOM_DASHBOARD_SECTION_DEFINITION.name ||
sectionName === CIAB_DASHBOARD_SECTION_DEFINITION.name ||
sectionName === A4A_DASHBOARD_SECTION_DEFINITION.name;

const isDashboardOmnibarPage =
( isDashboardEnv() || env === 'development' ) &&
( sectionName === DOTCOM_DASHBOARD_SECTION_DEFINITION.name ||
Expand Down Expand Up @@ -153,6 +159,7 @@ class Document extends Component {
branchName={ branchName }
inlineScriptNonce={ inlineScriptNonce }
faviconUrl={ headFaviconUrl }
allowZoom={ isDashboardSection }

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.

Would it be better to disable zoom on log-in page?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

😮‍💨 Yes you're probably right. You've highlighted that I'm basically taking a shortcut. Now I have to decide whether the shortcut is warranted 😭

I think the proper fix is that the login page (and basically all pages in Calypso, but there's fewer and fewer of them over time) should be using the input controls from @wordpress/components which mean that the auto zoom doesn't happen.

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.

We can move this forward and address it later 🙂

// Firefox can reuse the anonymous REST proxy prefetch after login; see https://github.com/Automattic/wp-calypso/pull/111842.
shouldPrefetchRestProxy={ ! app?.isFirefox }
>
Expand Down
Loading