Portal Iframe Improvements in Admin X (#19377)

refs PROD-4

- removed unnecessary props passed into the PortalFrame component.
This commit is contained in:
Ronald Langeveld 2023-12-14 09:42:30 +02:00 committed by GitHub
parent 3fef668394
commit 0dc4ac380c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,12 +2,11 @@ import React, {useCallback, useEffect, useRef, useState} from 'react';
type PortalFrameProps = {
href: string;
onLoaded?: (iframe: HTMLIFrameElement) => void;
onDestroyed?: () => void;
selectedTab?: string;
}
const PortalFrame: React.FC<PortalFrameProps> = ({href, onLoaded, onDestroyed, selectedTab}) => {
const PortalFrame: React.FC<PortalFrameProps> = ({href, onDestroyed, selectedTab}) => {
if (!selectedTab) {
selectedTab = 'signup';
}
@ -17,12 +16,11 @@ const PortalFrame: React.FC<PortalFrameProps> = ({href, onLoaded, onDestroyed, s
// Handler for making the iframe visible, memoized with useCallback
const makeVisible = useCallback(() => {
setTimeout(() => {
setIsInvisible(false);
if (onLoaded && iframeRef.current) {
onLoaded(iframeRef.current);
if (iframeRef.current) {
setIsInvisible(false);
}
}, 100); // Delay to allow scripts to render
}, [onLoaded]); // Dependencies for useCallback
}, [iframeRef]); // Dependencies for useCallback
// Effect for attaching message listener
useEffect(() => {