From f496866a26a492ea65c0b7dc3bc9324a71c7158b Mon Sep 17 00:00:00 2001 From: xiamiao1121 <74885998+xiamiao1121@users.noreply.github.com> Date: Wed, 24 Jul 2024 17:21:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(tree):=20=E4=BF=AE=E5=A4=8DFirefox=E4=B8=AD?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=8B=96=E6=8B=BD=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98(#2941)=20(#2943)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(tree): 修复Firefox中组件拖拽报错问题(#2941) * chore(tree): 生成变更记录文件 * chore(tree): 添加注释 --------- Co-authored-by: xiamiao --- .changeset/chilly-squids-talk.md | 5 +++++ .changeset/lemon-fireants-glow.md | 5 +++++ packages/ui/tree/src/TreeNode.tsx | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .changeset/chilly-squids-talk.md create mode 100644 .changeset/lemon-fireants-glow.md diff --git a/.changeset/chilly-squids-talk.md b/.changeset/chilly-squids-talk.md new file mode 100644 index 000000000..3a9377e71 --- /dev/null +++ b/.changeset/chilly-squids-talk.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/tree": patch +--- + +fix: 修复 Firefox 中组件拖拽报错问题 diff --git a/.changeset/lemon-fireants-glow.md b/.changeset/lemon-fireants-glow.md new file mode 100644 index 000000000..1ee2ece32 --- /dev/null +++ b/.changeset/lemon-fireants-glow.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +fix(tree): 修复 Firefox 中组件拖拽报错问题 diff --git a/packages/ui/tree/src/TreeNode.tsx b/packages/ui/tree/src/TreeNode.tsx index c1ded2867..ec3810735 100644 --- a/packages/ui/tree/src/TreeNode.tsx +++ b/packages/ui/tree/src/TreeNode.tsx @@ -92,6 +92,8 @@ export const TreeNode = forwardRef((props, const { id } = eventNodeRef.current + // 清空数据,下面会重新设置 + evt.dataTransfer.clearData() evt.stopPropagation() setIsDragging(true) @@ -108,7 +110,9 @@ export const TreeNode = forwardRef((props, (evt: React.DragEvent) => { evt.preventDefault() evt.stopPropagation() - evt.dataTransfer.clearData() + // issue: https://github.com/XiaoMi/hiui/issues/2941 + // 在firefox中拖拽结束后,清除数据会报错,Modifications are not allowed for this document,所以这里注释掉 + // evt.dataTransfer.clearData() dragNodeRef.current = null setDirection(null) setIsDragging(false)