question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Cannot read property 'x' of undefined in at DiagramEngine._this.calculateMatrixDimensions

See original GitHub issue

In demo drag -and-drop(large application) example, If smart routing is enabled for DiagramWidget and user tried to drag and drop Node from side menu to workspacepanel area (diagram widget area/graph area), it throughs error in console as Uncaught TypeError: Cannot read property ‘x’ of undefined in at DiagramEngine._this.calculateMatrixDimensions

This occurs only if smart routing is enabled for DiagramWidget and there is no Node/Link/Port drawn on that DigramWidget, then drag and drop the Node from side panel and try to move around workspacel area.

Steps to reproduce:

  1. Go to file: .demos/demo-drag-and-drop/Application.ts

  2. From that file remove the code that create default nodes, links and ports i.e

     //3-A) create a default node
     var node1 = new SRD.DefaultNodeModel("Node 1", "rgb(0,192,255)");
     let port = node1.addOutPort("Out");
     node1.setPosition(100, 100);
    
     //3-B) create another default node
     var node2 = new SRD.DefaultNodeModel("Node 2", "rgb(192,255,0)");
     let port2 = node2.addInPort("In");
     node2.setPosition(400, 100);
    
     // link the ports
     let link1 = port.link(port2);
    
     this.activeModel.addAll(node1, node2, link1);
    
  3. Go to file Go to file: .demos/demo-drag-and-drop/components/BodyWidget.tsx

  4. From that file, add property to DiagramWidget to enable smart routing <DiagramWidget className="srd-demo-canvas" diagramEngine={this.props.app.getDiagramEngine()} smartRouting={true} />

  5. Run the project. ie. npm run storybook.

  6. On application, under Advance Techniques-> Large application, try to drag In Node from side panel inside DiagramWidget then move around that In Node within area. Look inside console of browser, you will found the same error.

ezgif com-video-to-gif

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:8
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
AnderLuizcommented, Mar 27, 2019

Same behavior.

added engine.recalculatePortsVisually(); before this.forceUpdate(); on onDrop event. Worked for me with version 5.2.1

1reaction
AnderLuizcommented, Jul 26, 2019

@frank-martinez-27 , before this line

this.props.app.getDiagramEngine().recalculatePortsVisually()

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read property 'X' of undefined ...
I see an issue with your loop which would cause an undefined property error. index will be out of range when the function...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
typeerror can not read property x of null - YouTube
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
Read more >
Uncaught TypeError : Cannot read properties of undefined
Looking for ways to handle Uncaught TypeError: Cannot read property of undefined in JavaScript? This guide will help you to catch errors.
Read more >
Uncaught TypeError: Cannot read property of null - iDiallo
Uncaught TypeError : Cannot read property 'value' of null ... CSS/mainStyle.css"> <link rel="shortcut icon" type="image/x-png" href="../.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found