mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Portal Iframe Improvements in Admin X (#19377)
refs PROD-4 - removed unnecessary props passed into the PortalFrame component.
This commit is contained in:
parent
3fef668394
commit
0dc4ac380c
1 changed files with 4 additions and 6 deletions
|
@ -2,12 +2,11 @@ import React, {useCallback, useEffect, useRef, useState} from 'react';
|
||||||
|
|
||||||
type PortalFrameProps = {
|
type PortalFrameProps = {
|
||||||
href: string;
|
href: string;
|
||||||
onLoaded?: (iframe: HTMLIFrameElement) => void;
|
|
||||||
onDestroyed?: () => void;
|
onDestroyed?: () => void;
|
||||||
selectedTab?: string;
|
selectedTab?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PortalFrame: React.FC<PortalFrameProps> = ({href, onLoaded, onDestroyed, selectedTab}) => {
|
const PortalFrame: React.FC<PortalFrameProps> = ({href, onDestroyed, selectedTab}) => {
|
||||||
if (!selectedTab) {
|
if (!selectedTab) {
|
||||||
selectedTab = 'signup';
|
selectedTab = 'signup';
|
||||||
}
|
}
|
||||||
|
@ -17,12 +16,11 @@ const PortalFrame: React.FC<PortalFrameProps> = ({href, onLoaded, onDestroyed, s
|
||||||
// Handler for making the iframe visible, memoized with useCallback
|
// Handler for making the iframe visible, memoized with useCallback
|
||||||
const makeVisible = useCallback(() => {
|
const makeVisible = useCallback(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setIsInvisible(false);
|
if (iframeRef.current) {
|
||||||
if (onLoaded && iframeRef.current) {
|
setIsInvisible(false);
|
||||||
onLoaded(iframeRef.current);
|
|
||||||
}
|
}
|
||||||
}, 100); // Delay to allow scripts to render
|
}, 100); // Delay to allow scripts to render
|
||||||
}, [onLoaded]); // Dependencies for useCallback
|
}, [iframeRef]); // Dependencies for useCallback
|
||||||
|
|
||||||
// Effect for attaching message listener
|
// Effect for attaching message listener
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue