Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tree): 修复Firefox中组件拖拽报错问题(#2941) #2943

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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