mirror of
https://gitee.com/antv/g6.git
synced 2024-12-02 03:38:20 +08:00
fix: fix node not find for removed combo (#5975)
This commit is contained in:
parent
b9bc1f36fc
commit
3f624e0aa0
33
packages/g6/__tests__/bugs/element-remove-combo.spec.ts
Normal file
33
packages/g6/__tests__/bugs/element-remove-combo.spec.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { createGraph } from '@@/utils';
|
||||
|
||||
describe('element remove combo', () => {
|
||||
it('remove combo', async () => {
|
||||
const graph = createGraph({
|
||||
animation: true,
|
||||
data: {
|
||||
nodes: [
|
||||
{ id: 'node-1', data: {}, combo: 'combo-1' },
|
||||
{ id: 'node-2', data: {}, combo: 'combo-1' },
|
||||
{ id: 'node-3', data: {}, combo: 'combo-1' },
|
||||
],
|
||||
combos: [
|
||||
{ id: 'combo-1', data: {}, combo: 'combo-2' },
|
||||
{ id: 'combo-2', data: {}, style: {} },
|
||||
],
|
||||
},
|
||||
layout: {
|
||||
type: 'force',
|
||||
},
|
||||
});
|
||||
|
||||
await graph.draw();
|
||||
|
||||
graph.removeComboData(['combo-1']);
|
||||
|
||||
const draw = jest.fn(async () => {
|
||||
await graph.draw();
|
||||
});
|
||||
|
||||
expect(draw).not.toThrow();
|
||||
});
|
||||
});
|
@ -570,6 +570,7 @@ export class DataController {
|
||||
const { model } = this;
|
||||
|
||||
const id = idOf(datum);
|
||||
if (!model.hasNode(id)) return;
|
||||
const original = toG6Data(model.getNode(id));
|
||||
const value = mergeElementsData(original, datum);
|
||||
model.mergeNodeData(id, value);
|
||||
|
Loading…
Reference in New Issue
Block a user