diff --git a/packages/block-editor/src/components/block-mobile-toolbar/index.js b/packages/block-editor/src/components/block-mobile-toolbar/index.js index d5a0c9e6c488c1..2e1b9a13fc2bca 100644 --- a/packages/block-editor/src/components/block-mobile-toolbar/index.js +++ b/packages/block-editor/src/components/block-mobile-toolbar/index.js @@ -8,22 +8,6 @@ import { ifViewportMatches } from '@wordpress/viewport'; */ import BlockMover from '../block-mover'; -// This is a temporary fix for a couple of issues specific to Webkit on iOS. -// Without this fix the browser scrolls the mobile toolbar off-screen. -// Once supported in Safari we can replace this in favor of preventScroll. -// For details see issue #18632 and PR #18686 -// Specifically, we scroll `edit-post-editor-regions__body` to enable a fixed top toolbar. -// But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar. - -const isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1; -if ( isIphone ) { - document.addEventListener( 'focusin', function( ) { - setTimeout( () => { - window.scrollTo( 0, 0 ); - }, 150 ); - } ); -} - function BlockMobileToolbar( { clientId, moverDirection } ) { return ( <div className="block-editor-block-mobile-toolbar"> diff --git a/packages/edit-post/src/index.js b/packages/edit-post/src/index.js index 531f8e1c0267ee..83999f7bf80041 100644 --- a/packages/edit-post/src/index.js +++ b/packages/edit-post/src/index.js @@ -77,6 +77,22 @@ export function initializeEditor( id, postType, postId, settings, initialEdits ) console.warn( "Your browser is using Quirks Mode. \nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins." ); } + // This is a temporary fix for a couple of issues specific to Webkit on iOS. + // Without this hack the browser scrolls the mobile toolbar off-screen. + // Once supported in Safari we can replace this in favor of preventScroll. + // For details see issue #18632 and PR #18686 + // Specifically, we scroll `edit-post-editor-regions__body` to enable a fixed top toolbar. + // But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar. + + const isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1; + if ( isIphone ) { + document.addEventListener( 'focusin', function( ) { + setTimeout( () => { + window.scrollTo( 0, 0 ); + }, 150 ); + } ); + } + render( <Editor settings={ settings }