X6 icon indicating copy to clipboard operation
X6 copied to clipboard

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

Open nanfb opened this issue 2 years ago • 12 comments

问题描述

双击添加边上的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 ... ]

屏幕截图或视频(可选)

https://user-images.githubusercontent.com/56207464/236983109-3fab9e26-a0dd-4789-a083-fe5b657cb75b.mp4

补充说明(可选)

No response

nanfb avatar May 09 '23 03:05 nanfb

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

NewByVector avatar May 13 '23 13:05 NewByVector

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

nanfb avatar May 15 '23 01:05 nanfb

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

NewByVector avatar May 15 '23 07:05 NewByVector

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

nanfb avatar May 15 '23 08:05 nanfb

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

NewByVector avatar May 16 '23 01:05 NewByVector

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

iamjxc avatar Aug 22 '23 03:08 iamjxc

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

CasoMemory avatar Feb 20 '24 07:02 CasoMemory

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

devinkkk2023 avatar Apr 11 '24 02:04 devinkkk2023

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

    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();
    });

March-Wind avatar May 07 '24 06:05 March-Wind

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

gthdweb avatar Jun 04 '24 09:06 gthdweb