X6 icon indicating copy to clipboard operation
X6 copied to clipboard

嵌套节点node.clone({deep: true})无效

Open XueMeijing opened this issue 1 year ago • 3 comments

Describe the bug

嵌套节点node.clone({deep: true})无效,cloneNode.store.data.children有值,但是cloneNode.children和cloneNode._children没有值

image

clone.setChildren(embeds), _children 在这里设置了但还是空数组 image image

Your Example Website or App

https://codesandbox.io/p/sandbox/elastic-wood-shyyk8?file=%2Findex.ts%3A10%2C27

Steps to Reproduce the Bug or Issue

点击嵌套节点,复制的新节点没有子节点

Expected behavior

deep: true能正常工作

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 2.11.1]

Additional context

No response

XueMeijing avatar Mar 12 '24 02:03 XueMeijing

x6节点严格来说是没有层级的。 如果需要复制多个节点,需要自己写逻辑同时复制多个节点

lloydzhou avatar Mar 14 '24 02:03 lloydzhou

x6节点严格来说是没有层级的。 如果需要复制多个节点,需要自己写逻辑同时复制多个节点

但是文档上 https://x6.antv.antgroup.com/api/model/cell#clone 有deep: true配置,并且会返回{"2c81e38b-af3e-4c95-b09a-83736f20cdc4": newNode}这种map类型,但实际上返回的还是newNode这种 image image

另外我看copy会复制子节点,copy方法里用到的 cloneSubGraph 跟 node.clone 的逻辑好像差不多啊,传的参数应该一样,不知道啥情况 image image

XueMeijing avatar Mar 28 '24 08:03 XueMeijing

使用Cell.deepClone(this.cell),x6源码和文档不一致,clone({deep:true})也是调用这个方法,但是返回的时候从map里取出最父级返回了,不知道什么意思,感觉是个bug

bighhhh avatar May 21 '24 07:05 bighhhh