G6
G6 copied to clipboard
V5 选中状态bug
Describe the bug / 问题描述
然后点击第二个rect取消选中时 第一个又选中了 正常应该是 取消第二个rect选中时 其他元素都不选中
https://github.com/antvis/G6/assets/100757902/dc714734-054f-4e5e-bd53-3d8b4471fe0f
以下是html代码
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/@antv/[email protected]/dist/g6.min.js"></script>
</head>
<body>
<button id="btn">点击增加node</button>
<div id="container"></div>
<script>
const Graph = window.G6.Graph
const graph = new Graph({
container: document.getElementById("container"),
data: {
nodes: [
{
id: "node-1",
type: 'rect',
style: { x: 50, y: 100 },
// states: ['selected']
},
],
},
behaviors: [
{
key: 'click-select',
type: 'click-select',
},
{
key: 'drag-element',
type: 'drag-element',
},
],
x: 0,
y: 0,
})
graph.render()
let i = 1
document.getElementById('btn').addEventListener('click', () => {
graph.setElementState({
'node-1': []
})
graph.addNodeData([
{
id: `node-${++i}`,
type: 'rect',
style: { x: 200, y: 200 },
states: ['selected']
}
])
graph.render()
setTimeout(() => {
console.log(999, graph.getNodeData());
})
})
</script>
</body>
</html>
Reproduction link / 重现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
点击第一个rect选中 然后增加第二个rect (第二个rect调用api自动选中 同时取消第一个rect选中状态) 然后点击第二个rect取消选中 第一个rect就出现了选中的状态 感觉像是bug
G6 Version / G6 版本
🆕 5.x
Operating System / 操作系统
Windows
Browser / 浏览器
Chrome
Additional context / 补充说明
No response