diff --git a/packages/g6/__tests__/bugs/plugin-minimap-combo-collapsed.spec.ts b/packages/g6/__tests__/bugs/plugin-minimap-combo-collapsed.spec.ts new file mode 100644 index 00000000000..482ca3e44c6 --- /dev/null +++ b/packages/g6/__tests__/bugs/plugin-minimap-combo-collapsed.spec.ts @@ -0,0 +1,36 @@ +import { createGraph, sleep } from '@@/utils'; + +describe('bug: plugin-minimap-combo-collapsed', () => { + it('should be collapsed', async () => { + const graph = createGraph({ + animation: false, + data: { + nodes: [{ id: 'node1', combo: 'combo1' }, { id: 'node2' }], + edges: [{ source: 'node1', target: 'node2' }], + combos: [{ id: 'combo1' }], + }, + layout: { + type: 'grid', + }, + plugins: [ + { + key: 'minimap', + type: 'minimap', + size: [240, 160], + }, + ], + }); + + await graph.render(); + + await expect(graph).toMatchSnapshot(__filename); + + await sleep(1000); + graph.collapseElement('combo1'); + graph.translateElementBy('combo1', [100, 100]); + + await graph.render(); + + await expect(graph).toMatchSnapshot(__filename, 'update collapsed combo'); + }); +}); diff --git a/packages/g6/__tests__/snapshots/bugs/plugin-minimap-combo-collapsed/default.svg b/packages/g6/__tests__/snapshots/bugs/plugin-minimap-combo-collapsed/default.svg new file mode 100644 index 00000000000..e049ad89036 --- /dev/null +++ b/packages/g6/__tests__/snapshots/bugs/plugin-minimap-combo-collapsed/default.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/g6/__tests__/snapshots/bugs/plugin-minimap-combo-collapsed/update collapsed combo.svg b/packages/g6/__tests__/snapshots/bugs/plugin-minimap-combo-collapsed/update collapsed combo.svg new file mode 100644 index 00000000000..9c222725327 --- /dev/null +++ b/packages/g6/__tests__/snapshots/bugs/plugin-minimap-combo-collapsed/update collapsed combo.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/g6/src/plugins/minimap/index.ts b/packages/g6/src/plugins/minimap/index.ts index 6cbd7af6d66..99f7222a457 100644 --- a/packages/g6/src/plugins/minimap/index.ts +++ b/packages/g6/src/plugins/minimap/index.ts @@ -187,7 +187,9 @@ export class Minimap extends BasePlugin { const id = idOf(datum); ids.add(id); - const target = element!.getElement(id)!; + const target = element!.getElement(id); + if (!target) return; + const shape = target.getShape('key'); const cloneShape = this.shapes.get(id) || shape.cloneNode();