File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ class Widget extends Component {
127
127
this . reloadIframe = this . reloadIframe . bind ( this )
128
128
this . debouncedScroll = debounce ( this . focusIframe , DEBOUNCE_WAIT , this )
129
129
this . setIframeRef = this . setIframeRef . bind ( this )
130
+ this . sendFocusMessageToIframe = this . sendFocusMessageToIframe . bind ( this )
130
131
}
131
132
132
133
componentDidMount ( ) {
@@ -214,11 +215,9 @@ class Widget extends Component {
214
215
if ( this . props . enabledFullscreen ) return
215
216
216
217
const { iframeRef } = this . iframe
217
-
218
218
if ( ! iframeRef || ! iframeRef . contentWindow ) {
219
219
return
220
220
}
221
-
222
221
const isIframeInViewport = isElementInViewport ( iframeRef )
223
222
const canPostMessage =
224
223
this . state . isFormReady &&
@@ -227,13 +226,20 @@ class Widget extends Component {
227
226
iframeRef . contentWindow != null
228
227
229
228
if ( canPostMessage ) {
230
- iframeRef . contentWindow . postMessage ( 'embed-focus' , '*' )
231
- this . setState ( {
232
- isIframeFocused : true
233
- } )
229
+ this . setState ( { isIframeFocused : true } , this . sendFocusMessageToIframe )
234
230
}
235
231
}
236
232
233
+ sendFocusMessageToIframe ( ) {
234
+ const { iframeRef } = this . iframe
235
+ if ( ! iframeRef ) { return }
236
+
237
+ setTimeout (
238
+ ( ) => iframeRef . contentWindow . postMessage ( 'embed-focus' , '*' ) ,
239
+ 100
240
+ )
241
+ }
242
+
237
243
render ( ) {
238
244
const {
239
245
isFullscreen,
You can’t perform that action at this time.
0 commit comments