Skip to content

调用removeCells没有正确处理父子节点的关联关系 #5009

@thjxs

Description

@thjxs

问题描述

通过调用removeCells(...) 对应

protected removeCells(cells: Cell[], options: CollectionRemoveOptions) {
删除子节点时,未能处理与父节点解除关系的逻辑。

重现链接

重现步骤

import { Graph } from "@antv/x6";

const graph = new Graph({
  container: document.getElementById('app')!,
  width: 800,
  height: 600,
})

const parent = graph.addNode({
  x: 100,
  y: 100,
  width: 400,
  height: 300,
})

const child1 = graph.addNode({
  x: 150,
  y: 150,
  width: 100,
  height: 50,
})

parent.addChild(child1)


graph.removeCells([child1])

console.log(parent.toJSON().children)

预期行为

将父节点进行序列化之后,其children数组中不再包含已删除子节点的ID

平台

屏幕截图或视频(可选但最好有)

No response

补充说明(可选)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting for authorFurther information is requested from the author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions