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

Props are not passed to node #485

Open
kellerkind87 opened this issue Jul 20, 2022 · 3 comments
Open

Props are not passed to node #485

kellerkind87 opened this issue Jul 20, 2022 · 3 comments
Assignees
Labels

Comments

@kellerkind87
Copy link

Hi,
i am doing prototypes and an evaluation of libs like yours. First of all thank you for spending your time providing this great lib.

I think i found a bug.

If i add a node vie the addNode method the data is not passed to the underlying vue component as props.

Here is my code:

const id = document.getElementById("drawflow");
this.editor = new Drawflow(id, Vue, this);

this.editor.registerNode('ButtonNode', ButtonNode);
this.editor.reroute = true;
this.editor.reroute_fix_curvature = true;
this.editor.curvature = 1;
this.editor.start();

const data = {
  "label" : "someLabel"
}

this.editor.addNode('test2', 1, 1, 150, 300, '', data, 'ButtonNode', 'vue');

this is how the node is added starting at drawflow.js:1231

if(parseInt(this.render.version) === 3 ) {
  //Vue 3
  let wrapper = this.render.h(this.noderegister[html].html, this.noderegister[html].props, this.noderegister[html].options);
  wrapper.appContext = this.parent;
  this.render.render(wrapper,content);
 
} else {
  // Vue 2
  let wrapper = new this.render({
  parent: this.parent,
  render: h => h(this.noderegister[html].html, { props: this.noderegister[html].props }),
  ...this.noderegister[html].options
  }).$mount()
  //
  content.appendChild(wrapper.$el);
}

It seems like the data parameter is not used.
Possible way to solve: Maybe merge the data and this.noderegister[html].props

Or maybe i am doing sth wrong?

Thank you in advance.

some versions:

  • Vue: 2.7.4
  • drawflow: 0.0.59
kellerkind87 added a commit to kellerkind87/Drawflow that referenced this issue Jul 20, 2022
- merged data to props
@jerosoler jerosoler self-assigned this Jul 20, 2022
@jerosoler jerosoler added the Vue label Jul 20, 2022
@jerosoler
Copy link
Owner

If node data is not passed as props.

It is at the time of registration that the props can be passed.

editor.registerNode('name', component, props, options);

There are users who have problems receiving the data.
Even though it can be interesting to pass the data as props.
Examples passing props:

Maybe pass the values inside a parameter. Or use some parameter type "dataInProps" true/false.

I study it.

@kellerkind87
Copy link
Author

i added a PR: #486

@jerosoler
Copy link
Owner

Yes, I saw it. Thanks. I will check it.

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