修复预览手势取消后的点击抑制

取消、失焦、树切换和无效几何统一清理点击抑制状态

补充 pointercancel 后点击状态回归测试

同步 UI 编辑器预览交互技术方案
This commit is contained in:
2026-09-03 14:45:58 +08:00
parent d225fdae01
commit 3deebf0e90
3 changed files with 9 additions and 3 deletions
@@ -140,6 +140,7 @@ export function useNodeTransformInteraction({
const gesture = activeGestureRef.current;
if (gesture) releasePointer(gesture.target, gesture.pointerId);
activeGestureRef.current = null;
suppressNextNodeClickRef.current = false;
}, []);
useEffect(() => cancelGesture, [cancelGesture]);
@@ -250,12 +251,14 @@ export function useNodeTransformInteraction({
const gesture = activeGestureRef.current;
if (!gesture || !acceptsGestureEvent(event)) return;
event.stopPropagation();
if (gesture.hasMoved) suppressNextNodeClickRef.current = true;
if (!gesture.hasMoved && isInsidePreview(event, previewRef)) {
const cleanPointerUpInside =
!gesture.hasMoved && isInsidePreview(event, previewRef);
const suppressClick = gesture.hasMoved || cleanPointerUpInside;
if (cleanPointerUpInside) {
canvas.selectNode(gesture.hitNodeId);
suppressNextNodeClickRef.current = true;
}
cancelGesture();
if (suppressClick) suppressNextNodeClickRef.current = true;
},
[acceptsGestureEvent, cancelGesture, canvas, previewRef],
);
@@ -188,6 +188,7 @@ describe('useNodeTransformInteraction', () => {
result.current.onNodePointerCancel(pointerEvent(target, 2, 0, 0));
});
expect(canvasProjection.selectNode).not.toHaveBeenCalled();
expect(result.current.consumeNodeClick()).toBe(false);
});
it('does not select when a clean pointerup lands outside the preview', () => {