antvis/G6

Do you want to work on this issue?

You can request for a bounty in order to promote it!

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

myLazyProgrammer posted onGitHub

Describe the bug / é—®é¢˜ęčæ°

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

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

Parameter. creates edge positioning errors.

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 / 其他

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.

posted by myLazyProgrammer 2 months ago

Many custom apis are buggy The authorities need to take a closer look

posted by LWtower 16 days ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests