From ffd9aef908fd8a4da268e765257907d2215f1ea3 Mon Sep 17 00:00:00 2001 From: "Michael P. Pfeiffer" Date: Wed, 27 Nov 2019 10:20:48 +0100 Subject: [PATCH] temporary fix for issues caused by browser scrolling in mobile Safari --- .../src/components/block-mobile-toolbar/index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 2e1b9a13fc2bca..36b712cc012cb8 100644 --- a/packages/block-editor/src/components/block-mobile-toolbar/index.js +++ b/packages/block-editor/src/components/block-mobile-toolbar/index.js @@ -8,6 +8,19 @@ 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 +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 (