-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: Reset rendering after deleting all nodes #6855
base: v5
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces a fix for deleting the last node in a graph. It includes changes to the graph rendering logic to reset the rendering state when all nodes are destroyed. Additionally, it adds a test case to verify the deletion functionality and updates the demo and unit test files accordingly. Changes
🪧 TipsFor further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me. |
panel | ||
.add( | ||
{ | ||
Remove: () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name 'Remove' is misleading here as it actually adds a node. Consider renaming it to 'Add' for clarity.
packages/g6/src/runtime/element.ts
Outdated
// <zh/> 如果所有节点都销毁了,重置渲染状态 | ||
// <en/> If all nodes are destroyed, reset the rendering state | ||
if (this.getNodes().length === 0) { | ||
this.context.graph.reSetRenderingState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议把相关逻辑写到 destroyElement
的 after
中,每销毁一个节点后,就清除该节点相关的数据
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议把相关逻辑写到
destroyElement
的after
中,每销毁一个节点后,就清除该节点相关的数据
已完成 帮忙看看呢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ouy-o3o 没有看到相关变更呢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aarebecca 6d4c3dc 这个呢
packages/g6/src/runtime/graph.ts
Outdated
* <zh/> 重置渲染引擎状态 | ||
* <en/> Reset the rendering engine status | ||
*/ | ||
public reSetRenderingState(): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
名字就用 resetXxx 吧,reset 事一个单词。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
名字就用 resetXxx 吧,reset 事一个单词。
好的 已修改~
packages/g6/src/runtime/graph.ts
Outdated
* <zh/> 重置渲染引擎状态 | ||
* <en/> Reset the rendering engine status | ||
*/ | ||
public reSetRenderingState(): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以不用添加这个 API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get! 直接在内部完成了 感谢指点
@ouy-o3o 我刚确认了下,after 中 clearElement 方法会执行相关清理操作,现在额外调用的 clear 是为了解决什么问题吗 |
@Aarebecca 经过测试发现 clear这一步操作确实是无效的 已经删除 |
@ouy-o3o 那剩下调用 |
@Aarebecca 我今天尝试复现具体问题 这个pr是为了修复 #6828 却发现本地无法复现这个问题了 半个月前还可以稳定复现 直到我找到这个pr #6702 看起来是同一个问题 却不知道为什么半个月前可以复现.. |
No description provided.