Skip to content

Commit 6094b97

Browse files
authored
Fix focus issue on embed block (#517)
* Fix focus issue on embed block * Add invisible iframe overlay to prevent clicking iframed controls
1 parent e6d42c4 commit 6094b97

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

blocks/library/embed/index.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@ registerBlock( 'core/embed', {
1919
caption: children( 'figcaption' )
2020
},
2121

22-
edit( { attributes, isSelected, setAttributes } ) {
22+
edit( { attributes, setAttributes, focus, setFocus } ) {
2323
const { url, title, caption } = attributes;
2424

2525
return (
2626
<figure>
27-
<iframe src={ url } title={ title } />
28-
{ caption || isSelected ? (
27+
<div className="iframe-overlay">
28+
<iframe src={ url } title={ title } />
29+
</div>
30+
{ caption || !! focus ? (
2931
<Editable
3032
tagName="figcaption"
3133
placeholder={ wp.i18n.__( 'Write caption…' ) }
3234
value={ caption }
35+
focus={ focus }
36+
onFocus={ setFocus }
3337
onChange={ ( value ) => setAttributes( { caption: value } ) } />
3438
) : null }
3539
</figure>

editor/modes/visual-editor/style.scss

+18
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@
3636
&.is-selected:before {
3737
border-color: $light-gray-500;
3838
}
39+
40+
.iframe-overlay {
41+
position: relative;
42+
}
43+
44+
.iframe-overlay:before {
45+
content: '';
46+
display: block;
47+
position: absolute;
48+
top: 0;
49+
right: 0;
50+
bottom: 0;
51+
left: 0;
52+
}
53+
54+
&.is-selected .iframe-overlay:before {
55+
display: none;
56+
}
3957
}
4058

4159
.editor-visual-editor__block-controls {

languages/gutenberg.pot

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ msgstr ""
1919
msgid "Embed"
2020
msgstr ""
2121

22-
#: blocks/library/embed/index.js:31
22+
#: blocks/library/embed/index.js:33
2323
#: blocks/library/image/index.js:81
2424
msgid "Write caption…"
2525
msgstr ""

0 commit comments

Comments
 (0)