🐛 Fixed Portal icon misaligned in Preview (#19723)

no issue

- because we use hidden here, it prevents the Portal iFrame from
calculating the width and position correctly on the initial load.
- Changing it to `invisible` conditionally allows it to do the calculation correctly.
- Also had to reposition the loading indicator.
This commit is contained in:
Ronald Langeveld 2024-02-21 13:22:49 +02:00 committed by GitHub
parent 7c407af642
commit c64c0c2123
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 5 deletions

View File

@ -611,6 +611,7 @@ const AddOfferModal = () => {
const iframe = <PortalFrame
href={href || ''}
portalParent='offers'
/>;
return <PreviewModalContent
afterClose={() => {

View File

@ -249,6 +249,7 @@ const EditOfferModal: React.FC<{id: string}> = ({id}) => {
const iframe = <PortalFrame
href={href || ''}
portalParent='offers'
/>;
return offerById ? <PreviewModalContent

View File

@ -5,9 +5,10 @@ type PortalFrameProps = {
href: string;
onDestroyed?: () => void;
selectedTab?: string;
portalParent?: string;
}
const PortalFrame: React.FC<PortalFrameProps> = ({href, onDestroyed, selectedTab}) => {
const PortalFrame: React.FC<PortalFrameProps> = ({href, onDestroyed, selectedTab, portalParent}) => {
if (!selectedTab) {
selectedTab = 'signup';
}
@ -49,11 +50,19 @@ const PortalFrame: React.FC<PortalFrameProps> = ({href, onDestroyed, selectedTab
return null;
}
let loaderClassNames = 'mt-[-7%] flex h-screen items-center justify-center';
let loaderVisibility = 'hidden';
if (portalParent === 'preview') {
loaderClassNames = 'absolute z-50 mt-[-7%] flex h-screen items-center justify-center';
loaderVisibility = 'invisible';
}
return (
<>{isInvisible && <div className="mt-[-7%] flex h-screen items-center justify-center"><span><LoadingIndicator /></span></div>}
<>{isInvisible && <div className={loaderClassNames}><span><LoadingIndicator /></span></div>}
<iframe
ref={iframeRef}
className={!isInvisible && hasLoaded ? '' : 'hidden'}
className={!isInvisible && hasLoaded ? '' : loaderVisibility}
data-testid="portal-preview"
height="100%"
src={href}

View File

@ -36,7 +36,7 @@ const PortalPreview: React.FC<PortalPreviewProps> = ({
case 'account':
tabContents = (
<>
<PortalFrame href={href || ''} selectedTab={selectedTab} />
<PortalFrame href={href || ''} portalParent='preview' selectedTab={selectedTab} />
</>
);
break;
@ -46,7 +46,7 @@ const PortalPreview: React.FC<PortalPreviewProps> = ({
default:
tabContents = (
<>
<PortalFrame href={href || ''} selectedTab={selectedTab} />
<PortalFrame href={href || ''} portalParent='preview' selectedTab={selectedTab} />
</>
);
break;