Skip to content

Commit

Permalink
Fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Dec 11, 2020
1 parent 7279dce commit 2d87a7b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
20 changes: 4 additions & 16 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { useState, createPortal } from '@wordpress/element';
import { useState, createPortal, useCallback } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

const BODY_CLASS_NAME = 'editor-styles-wrapper';
Expand Down Expand Up @@ -126,16 +126,10 @@ function setHead( doc, head ) {
'<style>body{margin:0}</style>' + head;
}

export default function Iframe( {
contentRef,
children,
head,
style = {},
...props
} ) {
export default function Iframe( { contentRef, children, head, ...props } ) {
const [ iframeDocument, setIframeDocument ] = useState();

function setRef( node ) {
const setRef = useCallback( ( node ) => {
if ( ! node ) {
return;
}
Expand All @@ -159,17 +153,11 @@ export default function Iframe( {

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

return (
<iframe
{ ...props }
style={ {
display: 'block',
width: '100%',
height: '100%',
...style,
} }
ref={ setRef }
tabIndex="0"
title={ __( 'Editor canvas' ) }
Expand Down
10 changes: 10 additions & 0 deletions packages/e2e-tests/specs/experiments/multi-entity-editing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ describe( 'Multi-entity editor states', () => {
it( 'should not dirty an entity by switching to it in the template dropdown', async () => {
await visitSiteEditor();
await clickTemplateItem( 'Template Parts', 'header' );
await page.waitForFunction( () =>
Array.from( window.frames ).find(
( { name } ) => name === 'editor-canvas'
)
);

// Wait for blocks to load.
await canvas().waitForSelector( '.wp-block' );
Expand All @@ -153,6 +158,11 @@ describe( 'Multi-entity editor states', () => {

// Switch back and make sure it is still clean.
await clickTemplateItem( 'Templates', 'Front Page' );
await page.waitForFunction( () =>
Array.from( window.frames ).find(
( { name } ) => name === 'editor-canvas'
)
);
await canvas().waitForSelector( '.wp-block' );
expect( await isEntityDirty( 'header' ) ).toBe( false );
expect( await isEntityDirty( 'front-page' ) ).toBe( false );
Expand Down
9 changes: 3 additions & 6 deletions packages/edit-site/src/components/editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@
}
}

.interface-interface-skeleton__content {
// The iframe is scrollable, so no need for the content area to be
// scrollable too.
overflow: visible;
}

.edit-site-visual-editor {
position: relative;
height: 100%;

iframe {
display: block;
width: 100%;
height: 100%;
background-color: $white;
}
}
Expand Down

0 comments on commit 2d87a7b

Please sign in to comment.