FlowFuse / node-red-dashboard

https://dashboard.flowfuse.com
Apache License 2.0
159 stars 35 forks source link

Text input node in a subflow crashes Layout Order Editor #709

Closed phfeustel closed 22 hours ago

phfeustel commented 3 months ago

Current Behavior

Using a text input node in a subflow crashes Layout Order Editor.

Uncaught TypeError: Cannot read properties of undefined (reading 'type')
    at <anonymous>:753:84
    at Array.filter (<anonymous>)
    at <anonymous>:753:63
    at Object.eachNode (red.min.js?v=:16:57181)
    at Object.eachNode (red.min.js?v=:16:87852)
    at buildLayoutOrderEditor (<anonymous>:747:19)
    at refreshSidebarEditors (<anonymous>:905:13)
    at later (<anonymous>:44:38)

I dug a bit into it and I think the line to blame is this one: In my case, when looking into the JS object and also the exported flow JSON env on the subflow does not have any ui property.

So, one way to fix this, could be to switch the comparisons from: subflowDef.env.filter(env => env.ui.type === 'conf-types' && env.type === 'ui-group') to subflowDef.env.filter(env => env.type === 'ui-group' && env.ui.type === 'conf-types')

Expected Behavior

After adding a text input node in a sub flow the layout order editor is still functional.

Steps To Reproduce

  1. Create a page
  2. Create a subflow containing a text input node
  3. Add the sublfow to the page
  4. See the contents of the Dashboard 2.0 Layout Order Editor disappear

Environment

Have you provided an initial effort estimate for this issue?

I am not a FlowFuse team member

joepavitt commented 3 months ago

fyi @Steve-Mcl

colinl commented 3 months ago

Using node-red 4.0.0 Beta 1 I am not able to replicate the issue. I thought it was necessary to use v4 when using dashboard nodes in a subflow.

phfeustel commented 3 months ago

@colinl Thanks for the hint. Would you please point me to the documentation on this?

phfeustel commented 3 months ago

@colinl I think I found what you meant: https://dashboard.flowfuse.com/user/subflows.html#configuring-subflows-for-dashboard-2-0

But luckily my use case does not need configurable ui-groups; the group where the text input should be displayed in is static.

In any way, I guess, the bug mentioned above is worth fixing.

joepavitt commented 3 months ago

@phfeustel Node-RED 4.0+ is needed for Dashboard 2.0 nodes to work in a subflow - in all occasions, not just when using a group.

If you're hitting this problem in Node-RED 4.0+, then please let us know.

phfeustel commented 3 months ago

@joepavitt thanks for the feedback.

I did a quick retest on Node-RED: 4.0.0-beta.: Same issue; I think the comparison code from above is just bugged and needs switching the conditions.

image
colinl commented 3 months ago

Just checking, did you restart node red? As I said, I don't see the issue.

phfeustel commented 3 months ago

Yes, I'm using node red in docker: Stop the 3.1.3; pulled the 4.0.0-beta image; started this and then did a full page refresh in the browser.

phfeustel commented 2 months ago

@joepavitt Any update or ETA?

As a side node: I patched the line above in my local installation and it is running now for 3 weeks stable. Should I open an pull request?

joepavitt commented 2 months ago

Should I open an pull request?

please, PRs are always welcome, never need to ask for permission :)

phfeustel commented 22 hours ago

Closed by https://github.com/FlowFuse/node-red-dashboard/pull/800