node-red-dashboard icon indicating copy to clipboard operation
node-red-dashboard copied to clipboard

Text input node in a subflow crashes Layout Order Editor

Open phfeustel opened this issue 1 year ago • 10 comments

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

  • Dashboard version: 1.4.1
  • Node-RED version: 3.1.3
  • Node.js version: 16.20.2
  • npm version: 8.19.4
  • Platform/OS: macOS Ventura 13.4.1 (22F82)
  • Browser: ARc Version 1.35.0 (47750) Chromium Engine Version 123.0.6312.59

Have you provided an initial effort estimate for this issue?

I am not a FlowFuse team member

phfeustel avatar Mar 26 '24 14:03 phfeustel

fyi @Steve-Mcl

joepavitt avatar Mar 27 '24 09:03 joepavitt

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.

colinl avatar Mar 27 '24 09:03 colinl

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

phfeustel avatar Mar 27 '24 10:03 phfeustel

@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.

phfeustel avatar Mar 27 '24 10:03 phfeustel

@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.

joepavitt avatar Mar 27 '24 14:03 joepavitt

@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

phfeustel avatar Mar 27 '24 14:03 phfeustel

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

colinl avatar Mar 27 '24 14:03 colinl

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 avatar Mar 27 '24 15:03 phfeustel

@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?

phfeustel avatar Apr 17 '24 11:04 phfeustel

Should I open an pull request?

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

joepavitt avatar Apr 17 '24 12:04 joepavitt

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

phfeustel avatar Jul 02 '24 12:07 phfeustel