fix(k8s): YAML 弹框 Portal 到 body 修复居中偏移

PageTransition 的 transform 会使 fixed 弹框相对页面定位而非视口,
YamlViewer 尺寸较大时容易跑出可视区。统一用 ModalOverlay Portal。
This commit is contained in:
Logan.Li committed 2026-06-26 15:04:08 +08:00
1 parent 025e74ff4d
commit 729f25e068
4 files changed
+42 -9

No files matched your search

@@ -4,6 +4,7 @@
import { useState, useEffect, useMemo} from 'react';
import { X, Copy, Check, Save, Loader2, Sparkles} from 'lucide-react';
import { Button } from '@/components/ui/button';
import { ModalOverlay } from '@/components/ui/modal-overlay';
import { useToast } from '@/hooks/use-toast';
import { kubernetesApi } from '@/api';
import { cleanYAML } from './k8s-yaml-utils';
@@ -186,10 +187,13 @@ export function YamlViewer({ clusterCode, namespace, resource, name, onClose, on
);
}
// 弹窗模式(原有行为)
// 弹窗模式 — Portal 到 body,避免 PageTransition transform 导致偏移 // Logan.Li
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60" onClick={onClose}>
<div className="bg-slate-900 border border-slate-700 rounded-xl w-[92vw] max-w-5xl h-[88vh] flex flex-col shadow-2xl" onClick={e => e.stopPropagation()}>
<ModalOverlay onClose={onClose}>
<div
className="bg-slate-900 border border-slate-700 rounded-xl w-[92vw] max-w-5xl max-h-[85vh] flex flex-col shadow-2xl"
onClick={(e) => e.stopPropagation()}
>
{/* Header */}
<div className="flex items-center justify-between p-4 border-b border-slate-700">
<div>
@@ -260,6 +264,6 @@ export function YamlViewer({ clusterCode, namespace, resource, name, onClose, on
)}
</div>
</div>
</div>
</ModalOverlay>
);
}