fix: fix node not find for removed combo (#5975)

This commit is contained in:
Aaron 2024-07-03 22:54:12 +08:00 committed by GitHub
parent b9bc1f36fc
commit 3f624e0aa0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 0 deletions

View 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();
});
});

View File

@ -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);