Skip to content

Commit

Permalink
move hack to edit post index
Browse files Browse the repository at this point in the history
  • Loading branch information
frontdevde committed Dec 4, 2019
1 parent 52b5b74 commit 648be73
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 0 additions & 16 deletions packages/block-editor/src/components/block-mobile-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
16 changes: 16 additions & 0 deletions packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit 648be73

Please sign in to comment.