Merge branch 'next' into develop

This commit is contained in:
nocobase[bot] 2025-04-17 06:31:20 +00:00
commit 11b57d0de4
2 changed files with 8 additions and 4 deletions

View File

@ -67,21 +67,24 @@ const ActionModalContent: FC<{ footerNodeName: string; field: any; schema: any }
); );
export function useDelayedVisible(visible: boolean, delay = 200) { export function useDelayedVisible(visible: boolean, delay = 200) {
const [ready, setReady] = useState(false); const [ready, setReady] = useState(delay === 0);
useEffect(() => { useEffect(() => {
if (ready) {
return;
}
if (visible) { if (visible) {
const timer = setTimeout(() => setReady(true), delay); const timer = setTimeout(() => setReady(true), delay);
return () => clearTimeout(timer); return () => clearTimeout(timer);
} else { } else {
setReady(false); setReady(false);
} }
}, [visible]); }, [delay, ready, visible]);
return ready; return ready;
} }
export const InternalActionModal: React.FC<ActionDrawerProps<ModalProps>> = observer( export const InternalActionModal: React.FC<ActionDrawerProps<ModalProps>> = observer(
(props) => { (props) => {
const { footerNodeName = 'Action.Modal.Footer', width, zIndex: _zIndex, ...others } = props; const { footerNodeName = 'Action.Modal.Footer', width, zIndex: _zIndex, delay = 200, ...others } = props;
const { visible, setVisible, openSize = 'middle', modalProps } = useActionContext(); const { visible, setVisible, openSize = 'middle', modalProps } = useActionContext();
const actualWidth = width ?? openSizeWidthMap.get(openSize); const actualWidth = width ?? openSizeWidthMap.get(openSize);
const schema = useFieldSchema(); const schema = useFieldSchema();
@ -102,7 +105,7 @@ export const InternalActionModal: React.FC<ActionDrawerProps<ModalProps>> = obse
} }
const zIndex = getZIndex('modal', _zIndex || parentZIndex, props.level || 0); const zIndex = getZIndex('modal', _zIndex || parentZIndex, props.level || 0);
const ready = useDelayedVisible(visible, 200); // 200ms 与 Modal 动画时间一致 const ready = useDelayedVisible(visible, delay); // 200ms 与 Modal 动画时间一致
return ( return (
<ActionContextNoRerender> <ActionContextNoRerender>

View File

@ -92,6 +92,7 @@ export type ActionDrawerProps<T = DrawerProps> = T & {
footerNodeName?: string; footerNodeName?: string;
/** 当前弹窗嵌套的层级 */ /** 当前弹窗嵌套的层级 */
level?: number; level?: number;
delay?: number;
}; };
export type ComposedActionDrawer<T = DrawerProps> = React.FC<ActionDrawerProps<T>> & { export type ComposedActionDrawer<T = DrawerProps> = React.FC<ActionDrawerProps<T>> & {