Skip to content

Commit

Permalink
Add an overlay to the html block preview to fix block selection in Fi…
Browse files Browse the repository at this point in the history
…refox (#20425)

* Stop clicks to focus being trapped in sandboxed iframe so block can be reselected
  • Loading branch information
glendaviesnz authored Feb 26, 2020
1 parent 8b241c9 commit 41a0d8b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/block-library/src/html/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,20 @@ class HTMLEdit extends Component {
<Disabled.Consumer>
{ ( isDisabled ) =>
isPreview || isDisabled ? (
<SandBox
html={ attributes.content }
styles={ styles }
/>
<>
<SandBox
html={ attributes.content }
styles={ styles }
/>
{ /*
An overlay is added when the block is not selected in order to register click events.
Some browsers do not bubble up the clicks from the sandboxed iframe, which makes it
difficult to reselect the block.
*/ }
{ ! this.props.isSelected && (
<div className="block-library-html__preview-overlay"></div>
) }
</>
) : (
<PlainText
value={ attributes.content }
Expand Down
8 changes: 8 additions & 0 deletions packages/block-library/src/html/editor.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
.wp-block-html {
margin-bottom: $default-block-margin;

.block-library-html__preview-overlay {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}

.block-editor-plain-text {
font-family: $editor-html-font;
color: $dark-gray-800;
Expand Down

0 comments on commit 41a0d8b

Please sign in to comment.