-
Notifications
You must be signed in to change notification settings - Fork 313
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
[Tabs文档] [可拖拽的选项卡]示例代码有问题 #2988
Comments
👋 @zindler323,感谢给 TDesign 提出了 issue。 |
我一开始使用时也省去了debounce,但是发现在相邻两个tab交换时,如果拖动过慢会瞬间交换两次,从而有莫名其妙的一个bug。因此最后我还是使用了debounce |
看各自喜欢,防抖或者节流,甚至不用也行,因人而异,但是目前demo使用debounce那就继续使用这个好了,然后欢迎PR来修复目前这个demo的bug!!! |
之前没仔细看,没看里面防抖执行的情况,把 |
事实上还存在个函数缓存失效问题。 useCallback(() => setState(pre => ...), [])可能好点。 |
這需要你們自己來決定,要麼使用 |
不要在这里用防抖吧,内部的拖拽不感知不到排序回调是否执行成功,默认每次结束都会更新一个最新的 index,导致没办法感知到实际的顺序。 |
tdesign-react 版本
官网demo版本
重现链接
https://tdesign.tencent.com/react/components/tabs#%E5%8F%AF%E6%8B%96%E6%8B%BD%E7%9A%84%E9%80%89%E9%A1%B9%E5%8D%A1
重现步骤
const onDragSort1 = useCallback( () => debounce(({ currentIndex, targetIndex }) => { const temp = tabList1[currentIndex]; tabList1[currentIndex] = tabList1[targetIndex]; tabList1[targetIndex] = temp; setTabList1([...tabList1]); }, 500), [tabList1], );
期望结果
const [onDragSort1] = useState(() => debounce(({ currentIndex, targetIndex }) => setTabList1((pre) => { const newValue = [...pre]; const temp = newValue[currentIndex]; newValue[currentIndex] = newValue[targetIndex]; newValue[targetIndex] = temp; return newValue; }), 500))
实际结果
1
框架版本
No response
浏览器版本
No response
系统版本
No response
Node版本
No response
补充说明
No response
The text was updated successfully, but these errors were encountered: