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

[Bug]: Custom node using create-edge API shows an error #6778

Open
2 of 10 tasks
myLazyProgrammer opened this issue Feb 17, 2025 · 1 comment
Open
2 of 10 tasks

[Bug]: Custom node using create-edge API shows an error #6778

myLazyProgrammer opened this issue Feb 17, 2025 · 1 comment
Labels
bug 🐛 Something isn't working

Comments

@myLazyProgrammer
Copy link

Describe the bug / 问题描述

When using custom nodes (html/jsx/react), add to the behaviors.

 {
      type: 'create-edge',
      trigger: 'click',
 },

Parameter. creates edge positioning errors.

Reproduction link / 复现链接

https://g6.antv.vision/zh/examples/element/custom-node#react-node

Steps to Reproduce the Bug or Issue / 重现步骤

By adding the above parameters to the behaviors parameter in the official code, the error bug can be reproduced.

Image

Version / 版本

🆕 5.x

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

  • Chrome
  • Edge
  • Firefox
  • Safari (Limited support / 有限支持)
  • IE (Nonsupport / 不支持)
  • Others / 其他
@myLazyProgrammer myLazyProgrammer added the waiting for maintainer Triage or intervention needed from a maintainer. label Feb 17, 2025
@myLazyProgrammer
Copy link
Author

Image
The part of the source code that causes the error is shown in the figure. The address is https://github.com/antvis/G6/blob/v5/packages/g6/src/behaviors/create-edge.ts#L117. The issue arises because when the addEdge function is triggered, a node is generated. If a node is configured in the config as an HTML/React/JSX node, the generated node will also be the configured node, leading to incorrect positioning. The current workaround is to use function configuration when configuring the React component, so that when the ID generated by add-edge is used, it does not return a DOM node.

                type: 'react',
                style: {
                    component: (data) => {
                        if (
                            !['g6-create-edge-assist-node-id'].includes(data.id)
                        ) {
                            return <CommonNode data={data} />;
                        }
                    },
                },
            }

I hope the official team can address the scenario of custom nodes in the API.

@zhongyunWan zhongyunWan added bug 🐛 Something isn't working and removed waiting for maintainer Triage or intervention needed from a maintainer. labels Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants