Skip to content

Commit

Permalink
fix: the initial values of some nodes are not set by default (#6075)
Browse files Browse the repository at this point in the history
Co-authored-by: 王璨 <[email protected]>
  • Loading branch information
MusicTen and 王璨 authored Jul 22, 2024
1 parent 3ac8a02 commit c3058dc
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/g6/__tests__/bugs/element-node-update-badge.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { createGraph } from '../utils';

describe('bug: element-node-update-badge', () => {
it('should update node badge', async () => {
const graph = createGraph({
animation: false,
node: {
style: {
badge: true,
badges: [{ text: '1' }],
badgeFill: 'white',
badgeBackgroundFill: 'red',
},
},
data: {
nodes: [{ id: 'node-0', style: { x: 100, y: 100 }, states: ['inactive'] }],
},
});

await graph.render();

await expect(graph).toMatchSnapshot(__filename);

graph.setElementState('node-0', []);

await graph.render();

await expect(graph).toMatchSnapshot(__filename, 'update-node-badge');
});
});
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.
2 changes: 2 additions & 0 deletions packages/g6/src/themes/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export function create(tokens: ThemeTokens): Theme {
node: {
palette: nodePaletteOptions,
style: {
donutOpacity: 1,
badgeBackgroundOpacity: 1,
badgeFill: '#fff',
badgeFontSize: 8,
badgePadding: [0, 4],
Expand Down

0 comments on commit c3058dc

Please sign in to comment.