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

在cell:mouseleave的时候cell.removeTools({name:'button-remove'}) ,然而边上的edge-editor也会跟着一起被删除 #3574

Open
nanfb opened this issue May 9, 2023 · 10 comments
Labels
type: bug 缺陷 Defects and unexpected behaviors

Comments

@nanfb
Copy link

nanfb commented May 9, 2023

问题描述

双击添加边上的edge-editor,原有的功能是划入在cell上添加button-remove,移除的时候删除,但是他在移出的时候会将edge-editor一起个删除了

重现链接

https://codesandbox.io/s/silly-goldberg-ejilkq?file=/src/app.tsx

重现步骤

在边上双击然后鼠标移出边

预期行为

只删除button-remove

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox]
  • X6 版本: [1.28.2 ... ]

屏幕截图或视频(可选)

hand.mp4

补充说明(可选)

No response

@NewByVector NewByVector added type: discussion 讨论 Usage questions, guidance, and other discussions type: bug 缺陷 Defects and unexpected behaviors and removed type: discussion 讨论 Usage questions, guidance, and other discussions labels May 9, 2023
@NewByVector
Copy link
Contributor

现在确实有这个问题,在移除 button-remove 工具的时候会刷新所有工具,导致文本编辑消失。暂时还没有好的方式来解决。我们会继续跟踪这个问题。

@nanfb
Copy link
Author

nanfb commented May 15, 2023

是只有移除button-remove的时候会有这个问题吗?我可以使用自定义的工具规避这个问题吗?

@NewByVector
Copy link
Contributor

@nanfb 不是,是添加、删除任何工具都会导致 editor 刷新。

@nanfb
Copy link
Author

nanfb commented May 15, 2023

@NewByVector 为什么会有这样的设计呢?那这样的话removeTools传递参数还有什么意义呢?

@NewByVector
Copy link
Contributor

@nanfb 这样的设计确实存在一些问题,每次工具更新都会刷新所有工具,虽然一定程度上降低了维护的复杂性,但是在一些特殊交互,比如你的场景中就难以支持。我们好好考虑一下这块的设计。

@iamjxc
Copy link

iamjxc commented Aug 22, 2023

遇到类似的问题,恳请尽快解决:
graph.on('edge:mouseenter', ({ cell }) => { // 添加连线的端点方便移动位置, source-arrowhead, target-arrowhead
graph.on('edge:mouseleave', ({ cell }) => { // 删除 source-arrowhead, target-arrowhead, 导致 edge-editor 被无辜删除

@CasoMemory
Copy link

同遇到了,期待后续更好的实现方式

@devinkkk2023
Copy link

一般情况下可以隐藏工具而不是删除来解决问题。

@March-Wind
Copy link

暂时可以用未暴露出来的方法去实现

    graph.on('edge:mouseenter', (params) => {
      const buttonRemove = (params.view?.tools?.tools || []).find((tool) => tool.name === 'button-remove');
      buttonRemove?.show();
    });

    graph.on('edge:mouseleave', (params) => {
      const buttonRemove = (params.view?.tools?.tools || []).find((tool) => tool.name === 'button-remove');
      buttonRemove?.hide();
    });

@gthdweb
Copy link

gthdweb commented Jun 4, 2024

// edge hover移除删除按钮
graph.on('edge:mouseleave', ({ edge }) => {
setTimeout(() => {
//立即移除会导致edge-editor输入内容消失
edge.removeTool('button-remove');
}, 499);
});
暂时用了延迟移除解决了此问题,希望后续能有更优雅的解决方案

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 缺陷 Defects and unexpected behaviors
Projects
None yet
Development

No branches or pull requests

7 participants