Skip to content

Commit

Permalink
temporary fix for issues caused by browser scrolling in mobile Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
frontdevde authored and jasmussen committed Nov 27, 2019
1 parent 33d5914 commit ffd9aef
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/block-editor/src/components/block-mobile-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="block-editor-block-mobile-toolbar">
Expand Down

0 comments on commit ffd9aef

Please sign in to comment.