From f79ccccf44f3af0e161f7e459e70b1fbdf63963f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Thu, 3 Sep 2026 11:51:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A8=B3=E5=AE=9A=E9=A2=84=E8=A7=88=E6=89=8B?= =?UTF-8?q?=E5=8A=BF=E6=B8=85=E7=90=86=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 通过 ref 读取最新预览回调\n避免回调身份变化时重复取消进行中的手势 --- .../components/preview/useNodeTransformInteraction.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/useNodeTransformInteraction.ts b/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/useNodeTransformInteraction.ts index 3208dfba8..d2ac9e82a 100644 --- a/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/useNodeTransformInteraction.ts +++ b/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/useNodeTransformInteraction.ts @@ -100,15 +100,18 @@ export function useNodeTransformInteraction({ ) => void; }) { const activeGestureRef = useRef(null); + // Keep cleanup stable while still invoking the latest preview callback. + const onPreviewTransformRef = useRef(onPreviewTransform); + onPreviewTransformRef.current = onPreviewTransform; const cancelGesture = useCallback(() => { const gesture = activeGestureRef.current; if (gesture) { releasePointer(gesture.target, gesture.pointerId); - onPreviewTransform?.(gesture.nodeId, null); + onPreviewTransformRef.current?.(gesture.nodeId, null); } activeGestureRef.current = null; - }, [onPreviewTransform]); + }, []); useEffect(() => cancelGesture, [cancelGesture]);