Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix new node invisible after invoke graph.clear #6702

Merged
merged 1 commit into from
Jan 8, 2025
Merged

Conversation

Aarebecca
Copy link
Contributor

  • 修复调用 Graph.clear 后重新添加节点时,新节点不可见的问题

  • Fix the problem that new nodes are not visible when nodes are added again after calling Graph.clear.

Issues:

Copy link

Walkthrough

This pull request addresses an issue where new nodes become invisible after invoking Graph.clear and then adding nodes again. The changes ensure that the graph is properly cleared and redrawn, making new nodes visible.

Changes

File Summary
packages/g6/__tests__/bugs/graph-draw-after-clear.spec.ts Added a test to verify that the graph redraws correctly after being cleared and new data is added.
packages/g6/__tests__/snapshots/bugs/graph-draw-after-clear/default.svg Added a snapshot for the test case to ensure visual correctness.
packages/g6/src/runtime/data.ts Removed warning comments from the getChanges method.
packages/g6/src/runtime/element.ts Added a clear method to remove all elements and reset styles, and updated the destroy method to use clear.
packages/g6/src/runtime/graph.ts Updated the clear method to reset the model and element states, ensuring proper clearing of the graph.

const { model, element } = this.context;
model.setData({});
model.clearChanges();
element?.clear();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the element?.clear() method is correctly handling all elements and resetting the necessary states. This is crucial for the functionality of clearing and redrawing the graph.

@Aarebecca Aarebecca merged commit 6eb5c9e into v5 Jan 8, 2025
2 checks passed
@Aarebecca Aarebecca deleted the fix/clear-draw branch January 8, 2025 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant