Skip to content

Commit

Permalink
fix: mindmap demo duplicate node id, close #3256 (#3257)
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydzhou committed Feb 18, 2023
1 parent 9b4fa86 commit c510756
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions examples/x6-example-features/src/pages/case/mind.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,22 @@ export default class Example extends React.Component {
if (dataItem) {
let item: MindMapData | null = null
const length = dataItem.children ? dataItem.children.length : 0
let nid = `${id}-${length + 1}`
if (graph.hasCell(nid)) {
// 如果通过length + 1拼接出来的节点id在画布中存在了,就在id后面加上随机数
nid = nid + Math.random()
}
if (type === 'topic') {
item = {
id: `${id}-${length + 1}`,
id: nid,
type: 'topic-branch',
label: `分支主题${length + 1}`,
width: 100,
height: 40,
}
} else if (type === 'topic-branch') {
item = {
id: `${id}-${length + 1}`,
id: nid,
type: 'topic-child',
label: `子主题${length + 1}`,
width: 60,
Expand Down

0 comments on commit c510756

Please sign in to comment.