Skip to content

Commit 04d64ab

Browse files
author
Max Prilutskiy
authored
fix(DIST-713): Removed extra timing (#149)
1 parent 2c90dd7 commit 04d64ab

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/core/views/components/iframe.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Iframe extends Component {
2222
}
2323

2424
async handleLoad() {
25-
this.props.onLoad(this.iframeRef)
25+
await Promise.resolve(this.props.onLoad(this.iframeRef))
2626
await this.triggerIframeRedraw()
2727
}
2828

@@ -42,7 +42,7 @@ class Iframe extends Component {
4242
setTimeout(() => {
4343
this.iframeRef.style.display = 'block'
4444
resolve()
45-
}, 500)
45+
})
4646
} catch (err) {
4747
reject(err)
4848
}

src/core/views/popup.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ const popupWrapper = styled(BaseWrapper)`
6666
${({ size }) =>
6767
size &&
6868
`
69-
height: calc(${size}% - 80px);
70-
width: calc(${size}% - 80px);
69+
height: calc(${size}% - 80px);
70+
width: calc(${size}% - 80px);
7171
`}
7272
transition: all 300ms ease-out;
7373
`
@@ -258,17 +258,20 @@ class Popup extends Component {
258258
}
259259

260260
handleIframeLoad(iframeRef) {
261-
this.setState({ iframeLoaded: true }, () => {
262-
setTimeout(() => {
263-
if (this.state.isLoading) {
264-
this.updateIcon(<IconCloseImage alt="close-typeform" data-qa="popup-close-button" src={closeImg} />)
265-
this.handleSidePanelOpen()
266-
this.setState({ frameAnimate: true, isLoading: false })
267-
if (iframeRef && iframeRef.contentWindow) {
268-
iframeRef.contentWindow.focus()
261+
return new Promise((resolve) => {
262+
this.setState({ iframeLoaded: true }, () => {
263+
setTimeout(() => {
264+
if (this.state.isLoading) {
265+
this.updateIcon(<IconCloseImage alt="close-typeform" data-qa="popup-close-button" src={closeImg} />)
266+
this.handleSidePanelOpen()
267+
this.setState({ frameAnimate: true, isLoading: false })
268+
if (iframeRef && iframeRef.contentWindow) {
269+
iframeRef.contentWindow.focus()
270+
}
269271
}
270-
}
271-
}, 500)
272+
resolve()
273+
}, 500)
274+
})
272275
})
273276
}
274277

0 commit comments

Comments
 (0)