Skip to content

Commit

Permalink
fix: unexpected element clear (#6710)
Browse files Browse the repository at this point in the history
* fix: unexpected element clear

* chore: update version
  • Loading branch information
Aarebecca authored Jan 9, 2025
1 parent 8c20ec8 commit e22f7b7
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 80 deletions.
2 changes: 1 addition & 1 deletion packages/g6-extension-3d/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6-extension-3d",
"version": "0.1.15",
"version": "0.1.16",
"description": "3D extension for G6",
"keywords": [
"antv",
Expand Down
2 changes: 1 addition & 1 deletion packages/g6-extension-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6-extension-react",
"version": "0.1.16",
"version": "0.1.17",
"description": "Using React Component to Define Your G6 Graph Node",
"keywords": [
"antv",
Expand Down
2 changes: 1 addition & 1 deletion packages/g6-ssr/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6-ssr",
"version": "0.0.10",
"version": "0.0.11",
"description": "Support SSR for G6",
"keywords": [
"antv",
Expand Down
2 changes: 2 additions & 0 deletions packages/g6/__tests__/bugs/graph-draw-after-clear.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ it('graph draw after clear', async () => {

await graph.clear();

await expect(graph).toMatchSnapshot(__filename, 'blank');

await sleep(200);

graph.addData(data);
Expand Down
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: 1 addition & 1 deletion packages/g6/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6",
"version": "5.0.41",
"version": "5.0.42",
"description": "A Graph Visualization Framework in JavaScript",
"keywords": [
"antv",
Expand Down
9 changes: 7 additions & 2 deletions packages/g6/src/runtime/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export class ElementController {
}

public init() {
if (!this.container) {
this.initContainer();
}

private initContainer() {
if (!this.container || this.container.destroyed) {
const { canvas } = this.context;
this.container = canvas.appendChild(new Group({ className: 'elements' }));
}
Expand Down Expand Up @@ -854,7 +858,8 @@ export class ElementController {
* <en/> clear all elements
*/
public clear() {
this.container.children.forEach((element) => element.destroy());
this.container.destroy();
this.initContainer();
this.elementMap = {};
this.shapeTypeMap = {};
this.defaultStyle = {};
Expand Down
2 changes: 1 addition & 1 deletion packages/g6/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '5.0.41';
export const version = '5.0.42';

0 comments on commit e22f7b7

Please sign in to comment.