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

虚拟表格拖动无法正常工作 #48237

Open
yaowq opened this issue Apr 3, 2024 · 9 comments
Open

虚拟表格拖动无法正常工作 #48237

yaowq opened this issue Apr 3, 2024 · 9 comments

Comments

@yaowq
Copy link

yaowq commented Apr 3, 2024

Reproduction link

Edit on StackBlitz

Steps to reproduce

  1. 打开官网的“table拖拽手柄示例”
  2. 表格加入virtual 和 scroll属性
  3. 表格拖动手柄丢失,调试发现 children属性无法生效

What is expected?

虚拟表格拖动可以正常工作

What is actually happening?

虚拟表格显示异常

Environment Info
antd 5.16.0
React 18.2.0
System Windows 11
Browser Microsoft Edge 商业版 版本 123.0.2420.65 (正式版本) (64 位)
Copy link

stackblitz bot commented Apr 3, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@yoyo837
Copy link
Contributor

yoyo837 commented Apr 3, 2024

虚拟列表是通过 components.body 实现的,占用了这个属性,不支持用户自己的 components.body 了,感觉客户端是不是可以再加个警告?

@yoyo837
Copy link
Contributor

yoyo837 commented Apr 3, 2024

不对,好像已经支持了 components.body #47098

@yaowq
Copy link
Author

yaowq commented Apr 3, 2024

不对,好像已经支持了 components.body #47098

我也是看到支持了才开始用的,但似乎还有问题

@linxianxi
Copy link
Contributor

linxianxi commented Apr 3, 2024

https://stackblitz.com/edit/react-2ze7sa-woksuw?file=demo.tsx 先按这里的,官方的 demo 也会改成 Context 方式,现在 React 官方不推荐用 React.cloneElement 了。并且 virtual 下 Row 写法不同,要用 forwardRef 包一下,将 ref 和 setNodeRef 一起传递给 dom

@yaowq
Copy link
Author

yaowq commented Apr 3, 2024

首先,非常感谢,新写法下拖动按钮可以正常显示了,但似乎由于虚拟滚动的原因,行往下拖动一行直到超出屏幕外(假设有20条,可视区域只能显示10条,现在要拖动第一条到第15条下面),竖向滚动条不会随着移动,这样就只能在显示出来的元素进行拖动排序,超出屏幕外就不行了

@linxianxi
Copy link
Contributor

linxianxi commented Apr 3, 2024

首先,非常感谢,新写法下拖动按钮可以正常显示了,但似乎由于虚拟滚动的原因,行往下拖动一行直到超出屏幕外(假设有20条,可视区域只能显示10条,现在要拖动第一条到第15条下面),竖向滚动条不会随着移动,这样就只能在显示出来的元素进行拖动排序,超出屏幕外就不行了

这应该需要自己配合 Table ref scrollTo 来自己实现了,你自己先试试,后面有时间我也会尝试下

@yaowq
Copy link
Author

yaowq commented Apr 3, 2024

好的,再次感谢

@linxianxi
Copy link
Contributor

linxianxi commented Apr 29, 2024

滚动后拖拽位置会有点不准,但是只能做到这样了,影响不大。
https://stackblitz.com/edit/react-2ze7sa-1glg6d?file=demo.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants