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]: Segments tool throw errors #2044

Closed
ceitflow opened this issue Feb 14, 2023 · 5 comments
Closed

[Bug]: Segments tool throw errors #2044

ceitflow opened this issue Feb 14, 2023 · 5 comments
Labels

Comments

@ceitflow
Copy link
Contributor

ceitflow commented Feb 14, 2023

What happened?

Sometimes when using segments tool with links we can see errors in the console. I was able to reproduce this in Kitchensink demo as well:
kitch
err

Looks like the method onHandleChanging is assigning undefined in the vertices list, and this is further passed down to the link.

Version

3.6.3

What browsers are you seeing the problem on?

Chrome

What operating system are you seeing the problem on?

Windows, Linux

@ceitflow ceitflow added the bug label Feb 14, 2023
@kumilingus
Copy link
Contributor

@ceitflow, could you please share the JSON of the graph (or better the link JSON) when the error occurred?

@ceitflow
Copy link
Contributor Author

ceitflow commented Feb 14, 2023

@kumilingus Sure, here is a simplified JSON from our project with 2 rectangles with ports and a single link, to reproduce just use segments tool and pull the link down:

        "cells": [
          {
            "z": -1,
            "type": "standard.Link",
            "router": {
              "name": "manhattan"
            },
            "source": {
              "id": 4,
              "port": "right",
              "magnet": "portBody"
            },
            "target": {
              "id": 6,
              "port": "left",
              "magnet": "portBody"
            },
            "id": "cf1c72a2-6ebc-4f76-b17e-0ed0f0340504",
            "connector": {
              "name": "normal"
            },
          },
          {
            "portLabelMarkup": [],
            "ports": {
              "items": [
                {
                  "id": "right",
                  "group": "right",
                  "args": {
                    "dx": 2,
                    "dy": 0
                  }
                },
                {
                  "id": "left",
                  "group": "left",
                  "args": {
                    "dx": -2,
                    "dy": 0
                  }
                }
              ],
              "groups": {
                "right": {
                  "position": {
                    "name": "right"
                  },
                  "attrs": {
                    "root": {
                      "magnet-selector": "portBody"
                    },
                    "portBody": {
                      "magnet": true,
                      "r": 4,
                      "strokeWidth": 1,
                    },
                    "wrapper": {
                      "magnet": true,
                      "fill": "transparent",
                      "magnet-selector": "portBody",
                      "r": 24,
                    }
                  },
                  "markup": [
                    {
                      "tagName": "circle",
                      "selector": "wrapper"
                    },
                    {
                      "tagName": "circle",
                      "selector": "portBody"
                    }
                  ]
                },
                "left": {
                  "position": {
                    "name": "left"
                  },
                  "attrs": {
                    "root": {
                      "magnet-selector": "portBody"
                    },
                    "portBody": {
                      "magnet": true,
                      "r": 4,
                      "strokeWidth": 1,
                    },
                    "wrapper": {
                      "magnet": true,
                      "fill": "transparent",
                      "magnet-selector": "portBody",
                      "r": 24,
                    }
                  },
                  "markup": [
                    {
                      "tagName": "circle",
                      "selector": "wrapper"
                    },
                    {
                      "tagName": "circle",
                      "selector": "portBody"
                    }
                  ]
                }
              }
            },
            "type": "standard.Rectangle",
            "size": {
              "width": 224,
              "height": 48
            },
            "position": {
              "x": 512,
              "y": 320
            },
            "markup": [
              {
                "tagName": "rect",
                "selector": "body"
              },
            ],
            "id": 4,
          },
          {
            "portLabelMarkup": [],
            "ports": {
              "items": [
                {
                  "id": "right",
                  "group": "right",
                  "args": {
                    "dx": 2,
                    "dy": 0
                  }
                },
                {
                  "id": "left",
                  "group": "left",
                  "args": {
                    "dx": -2,
                    "dy": 0
                  }
                }
              ],
              "groups": {
                "right": {
                  "position": {
                    "name": "right"
                  },
                  "attrs": {
                    "root": {
                      "magnet-selector": "portBody"
                    },
                    "portBody": {
                      "magnet": true,
                      "r": 4,
                      "strokeWidth": 1,
                    },
                    "wrapper": {
                      "magnet": true,
                      "fill": "transparent",
                      "magnet-selector": "portBody",
                      "r": 24,
                    }
                  },
                  "markup": [
                    {
                      "tagName": "circle",
                      "selector": "wrapper"
                    },
                    {
                      "tagName": "circle",
                      "selector": "portBody"
                    }
                  ]
                },
                "left": {
                  "position": {
                    "name": "left"
                  },
                  "attrs": {
                    "root": {
                      "magnet-selector": "portBody"
                    },
                    "portBody": {
                      "magnet": true,
                      "r": 4,
                      "strokeWidth": 1,
                    },
                    "wrapper": {
                      "magnet": true,
                      "fill": "transparent",
                      "magnet-selector": "portBody",
                      "r": 24,
                    }
                  },
                  "markup": [
                    {
                      "tagName": "circle",
                      "selector": "wrapper"
                    },
                    {
                      "tagName": "circle",
                      "selector": "portBody"
                    }
                  ]
                }
              }
            },
            "type": "standard.Rectangle",
            "size": {
              "width": 224,
              "height": 48
            },
            "position": {
              "x": 992,
              "y": 320
            },
            "markup": [
              {
                "tagName": "rect",
                "selector": "body"
              },
            ],
            "id": 6,
          }
        ]
 }

@kumilingus
Copy link
Contributor

kumilingus commented Feb 14, 2023

The segment tool is meant to be used with normal router. It adjusts vertices, not route.

  1. We should mention this in the docs
  2. Perhaps we should throw an error saying not to use it with manhattan or orthogonal router. Mainly, we have to exit before the Cannot read properties of undefined exception.
  3. Do not show segment tools in the Kitchen Sink app for links with other than normal router.

If you want to use segment tools with orthogonal like router you can check out this CodePen. Introduces a custom element view that translates near vertices when moving.

@ceitflow
Copy link
Contributor Author

Thanks for clarification @kumilingus, I'll let my team know

@kumilingus
Copy link
Contributor

Fixed in #2334.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants