fix: vertical scrollbar appears when iframe block is set to full height (#6675)

This commit is contained in:
Katherine 2025-04-15 22:50:48 +08:00 committed by GitHub
parent 0f21f483f7
commit 91207a77f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -17,7 +17,7 @@ import {
useRequest, useRequest,
useVariables, useVariables,
} from '@nocobase/client'; } from '@nocobase/client';
import { Card, Spin } from 'antd'; import { Card, Spin, theme } from 'antd';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import RIframe from 'react-iframe'; import RIframe from 'react-iframe';
@ -37,6 +37,7 @@ export const Iframe: any = observer(
const { url, htmlId, mode = 'url', height, html, params, engine, ...others } = props; const { url, htmlId, mode = 'url', height, html, params, engine, ...others } = props;
const field = useField(); const field = useField();
const { t } = useTranslation(); const { t } = useTranslation();
const { token } = theme.useToken();
const targetHeight = useBlockHeight() || height; const targetHeight = useBlockHeight() || height;
const variables = useVariables(); const variables = useVariables();
const localVariables = useLocalVariables(); const localVariables = useLocalVariables();
@ -90,7 +91,9 @@ export const Iframe: any = observer(
}, [htmlContent, mode, url, variables, localVariables, params]); }, [htmlContent, mode, url, variables, localVariables, params]);
if ((mode === 'url' && !url) || (mode === 'html' && !htmlId)) { if ((mode === 'url' && !url) || (mode === 'html' && !htmlId)) {
return ( return (
<Card style={{ marginBottom: 24, height: isNumeric(targetHeight) ? `${targetHeight}px` : targetHeight }}> <Card
style={{ marginBottom: token.padding, height: isNumeric(targetHeight) ? `${targetHeight}px` : targetHeight }}
>
{t('Please fill in the iframe URL')} {t('Please fill in the iframe URL')}
</Card> </Card>
); );
@ -101,7 +104,7 @@ export const Iframe: any = observer(
<div <div
style={{ style={{
height: isNumeric(targetHeight) ? `${targetHeight}px` : targetHeight || '60vh', height: isNumeric(targetHeight) ? `${targetHeight}px` : targetHeight || '60vh',
marginBottom: '24px', marginBottom: token.padding,
border: 0, border: 0,
}} }}
> >