Skip to content

Commit

Permalink
fix(minimap): fix collapsed combo childrenNode getShape not found (#6120
Browse files Browse the repository at this point in the history
)

Co-authored-by: 王璨 <[email protected]>
  • Loading branch information
MusicTen and 王璨 authored Aug 5, 2024
1 parent f6d10cf commit 7ca88d0
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 1 deletion.
36 changes: 36 additions & 0 deletions packages/g6/__tests__/bugs/plugin-minimap-combo-collapsed.spec.ts
Original file line number Diff line number Diff line change
@@ -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');
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion packages/g6/src/plugins/minimap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ export class Minimap extends BasePlugin<MinimapOptions> {
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();

Expand Down

0 comments on commit 7ca88d0

Please sign in to comment.