Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Dec 11, 2020
1 parent 845ed02 commit 72f3936
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
30 changes: 19 additions & 11 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,27 +148,35 @@ function Iframe( { contentRef, children, head, ...props }, ref ) {
const { contentDocument } = node;
const { readyState } = contentDocument;

if ( readyState === 'interactive' || readyState === 'complete' ) {
setIframeDocument( contentDocument );
setHead( contentDocument, head );
setBodyClassName( contentDocument );
styleSheetsCompat( contentDocument );
bubbleEvents( contentDocument );
setBodyClassName( contentDocument );
contentRef.current = contentDocument.body;
if ( readyState !== 'interactive' && readyState !== 'complete' ) {
return false;
}

setIframeDocument( contentDocument );
setHead( contentDocument, head );
setBodyClassName( contentDocument );
styleSheetsCompat( contentDocument );
bubbleEvents( contentDocument );
setBodyClassName( contentDocument );
contentRef.current = contentDocument.body;

return true;
}

setDocumentIfReady();
if ( setDocumentIfReady() ) {
return;
}

// Document is not immediately loaded in Firefox.
node.addEventListener( 'load', setDocumentIfReady );
node.addEventListener( 'load', () => {
setDocumentIfReady();
} );
}, [] );

return (
<iframe
{ ...props }
ref={ mergeRefs( [ ref, setRef ] ) }
ref={ useCallback( mergeRefs( [ ref, setRef ] ), [] ) }
tabIndex="0"
title={ __( 'Editor canvas' ) }
name="editor-canvas"
Expand Down
6 changes: 5 additions & 1 deletion packages/e2e-test-utils/src/show-block-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
* Call this function to reveal it.
*/
export async function showBlockToolbar() {
// Move the mouse to disable the isTyping mode
// Move the mouse to disable the isTyping mode. We need at least three
// mousemove events for it to work across windows (iframe). With three
// moves, it's a guarantee that at least two will be in the same window.
// Two events are required for the flag to be unset.
await page.mouse.move( 50, 50 );
await page.mouse.move( 75, 75 );
await page.mouse.move( 100, 100 );
}

0 comments on commit 72f3936

Please sign in to comment.