窗口失焦时丢弃未提交的树拖拽

PreviewWorkspace.tsx 的 onWindowBlur 一并清掉 treeDragRef 与树拖拽预览偏移:失焦时浏览器不一定补 pointercancel,陈旧手势会被后续 pointerup 复用并把意外偏移写进文档
tests/previewRightPanDrag.test.tsx 补失焦后抬起不提交偏移的用例
This commit is contained in:
2026-09-24 16:07:56 +08:00
parent 134046f806
commit 76dfd74dea
2 changed files with 280 additions and 240 deletions
@@ -404,6 +404,17 @@ export function PreviewWorkspace({
rightPressSequenceRef.current = false;
rightPanRef.current = null;
setIsPanning(false);
// 失焦时浏览器不一定补 pointercancel:丢掉未提交的树拖拽,避免后续指针事件
// 复用陈旧手势把意外偏移写进文档。
const drag = treeDragRef.current;
if (drag) {
treeDragRef.current = null;
setPreviewTreeOffsets((current) => {
const next = new Map(current);
next.delete(drag.treeId);
return next;
});
}
};
window.addEventListener('keydown', onKeyDown);
window.addEventListener('keyup', onKeyUp);
File diff suppressed because it is too large Load Diff