fix iframe will take away the focus

This commit is contained in:
DiamondThree
2022-08-02 16:59:59 +08:00
parent e8f390a0d2
commit 6f340adf24

View File

@@ -61,10 +61,15 @@ export const useLazyIframe = (
iframe.src = link; iframe.src = link;
iframe.onload = () => { iframe.onload = () => {
setTimeout(() => { setTimeout(() => {
// Prevent iframe from scrolling parent container
// TODO W3C https://github.com/w3c/csswg-drafts/issues/7134
// https://forum.figma.com/t/prevent-figmas-embed-code-from-automatically-scrolling-to-it-on-page-load/26029/6
setIframeShow(true); setIframeShow(true);
}, timers); }, timers);
}; };
container.current.appendChild(iframe); if (container?.current) {
container.current.appendChild(iframe);
}
return () => { return () => {
iframe.remove(); iframe.remove();
}; };