From e726dc41b81a9a8d7183081c68676bf661f89a92 Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Tue, 8 Sep 2026 19:45:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BA=A6=E6=9D=9F=20AGC=20=E7=B4=A0?= =?UTF-8?q?=E6=9D=90=E5=80=99=E9=80=89=E5=BC=B9=E5=B1=82=E5=88=B0=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 类型提示改为固定定位并按输入框宽度约束 - 根据上下可用空间选择展开方向 - 避免弹层越过聊天栏覆盖其它区域 --- .../ResourceReferenceInput.tsx | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/apps/ai-game-creator-shell/src/features/project-workspace/ResourceReferenceInput.tsx b/apps/ai-game-creator-shell/src/features/project-workspace/ResourceReferenceInput.tsx index 7e87f6804..6fcb4a241 100644 --- a/apps/ai-game-creator-shell/src/features/project-workspace/ResourceReferenceInput.tsx +++ b/apps/ai-game-creator-shell/src/features/project-workspace/ResourceReferenceInput.tsx @@ -367,15 +367,48 @@ function ResourceReferenceEditor({ ); const renderMentionMenu: MenuRenderFn = useCallback( - (anchorElementRef, itemProps) => { - if (!anchorElementRef.current || itemProps.options.length === 0) { + (_anchorElementRef, itemProps) => { + const inputRect = rootRef.current?.getBoundingClientRect(); + if (!inputRect || itemProps.options.length === 0) { return null; } + const viewportPadding = 12; + const menuWidth = Math.min( + Math.max(280, inputRect.width), + Math.min(420, window.innerWidth - viewportPadding * 2), + ); + const left = Math.min( + Math.max(viewportPadding, inputRect.left), + Math.max( + viewportPadding, + window.innerWidth - menuWidth - viewportPadding, + ), + ); + const availableAbove = Math.max(0, inputRect.top - viewportPadding - 8); + const availableBelow = Math.max( + 0, + window.innerHeight - inputRect.bottom - viewportPadding - 8, + ); + const openAbove = availableBelow < 160 && availableAbove > availableBelow; + const maxHeight = Math.max( + 120, + Math.min(240, openAbove ? availableAbove : availableBelow), + ); + const top = openAbove + ? Math.max(viewportPadding, inputRect.top - maxHeight - 8) + : inputRect.bottom + 8; return createPortal(
{itemProps.options.map((option, index) => (
, - anchorElementRef.current, + document.body, ); }, [],