Skip to content

Commit

Permalink
fix(tree): 修复Firefox中组件拖拽报错问题(#2941) (#2943)
Browse files Browse the repository at this point in the history
* fix(tree): 修复Firefox中组件拖拽报错问题(#2941)

* chore(tree): 生成变更记录文件

* chore(tree): 添加注释

---------

Co-authored-by: xiamiao <[email protected]>
  • Loading branch information
xiamiao1121 and xiamiao authored Jul 24, 2024
1 parent 629731e commit f496866
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/chilly-squids-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/tree": patch
---

fix: 修复 Firefox 中组件拖拽报错问题
5 changes: 5 additions & 0 deletions .changeset/lemon-fireants-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

fix(tree): 修复 Firefox 中组件拖拽报错问题
6 changes: 5 additions & 1 deletion packages/ui/tree/src/TreeNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export const TreeNode = forwardRef<HTMLLIElement | null, TreeNodeProps>((props,

const { id } = eventNodeRef.current

// 清空数据,下面会重新设置
evt.dataTransfer.clearData()
evt.stopPropagation()

setIsDragging(true)
Expand All @@ -108,7 +110,9 @@ export const TreeNode = forwardRef<HTMLLIElement | null, TreeNodeProps>((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)
Expand Down

0 comments on commit f496866

Please sign in to comment.