fix(canvas): 拖入节点后清理残留手势状态(首次点击不再被当成收尾)
This commit is contained in:
1 parent
a4550d5654
commit
3565b5aec2
1 file changed
+16
@@ -887,6 +887,14 @@
|
||||
commitCanvas(refs.nodes.concat(moved), refs.edges.concat(es), refs.groups.concat(gs))
|
||||
} else {
|
||||
setSel([])
|
||||
// 拖入后清掉宿主的临时手势状态:原生拖放期间鼠标事件被浏览器吞掉,
|
||||
// pointerup 可能没走到画布,refs.bodyDown/box 会残留 ⇒ 第一次点击节点被当成「收尾」。
|
||||
try {
|
||||
refs.bodyDown = null; refs.groupDown = null; refs.drag = null; refs.box = null; refs.pan = null
|
||||
const ae = document.activeElement
|
||||
if (ae && typeof ae.blur === 'function') ae.blur()
|
||||
if (window.getSelection) window.getSelection().removeAllRanges()
|
||||
} catch (e) { /* ignore */ }
|
||||
setNotice({ type: 'ok', text: '✓ 已导入 ' + ns.length + ' 个节点 / ' + es.length + ' 条连线' })
|
||||
commitCanvas(ns, es, gs)
|
||||
}
|
||||
@@ -1105,6 +1113,14 @@
|
||||
commitCanvas(refs.nodes.concat([node]), undefined, undefined)
|
||||
// 插入后不选中:选中态下模板节点的变量输入框可编辑,点它就无法拖节点
|
||||
setSel([])
|
||||
// 原生拖放期间浏览器的鼠标事件被吞掉,pointerup 不会走到画布:
|
||||
// refs.bodyDown/box 等临时手势会残留,导致「第一次点节点」被当成收尾(点不动/选中文本)。
|
||||
try {
|
||||
refs.bodyDown = null; refs.groupDown = null; refs.drag = null; refs.box = null; refs.pan = null
|
||||
const ae = document.activeElement
|
||||
if (ae && typeof ae.blur === 'function') ae.blur()
|
||||
if (window.getSelection) window.getSelection().removeAllRanges()
|
||||
} catch (e) { /* ignore */ }
|
||||
setNotice({ type: 'ok', text: (hasVars ? '已插入提示词模板:' : '已插入提示词:') + (obj.name || '') })
|
||||
return
|
||||
} catch (err) { /* 非本应用拖入 */ }
|
||||
|
||||
Reference in new issue
Block a user