Create node with conditional properties (tabs)

I am developing a new node (in v3) that control motor movement.

Most of the properties are shared but some of them are conditional base of the motor operation mode, i.e., the user can choose to define propery1 or property2 but not both of them.

Can I something similar to tabs in the properties panel so the user can select what set of properties to define such that only the relevant properties are visible.
I would like to avoid creating multiple nodes since there are operation mode and the node function is similar.

MAYBE you need to have variables set by the user in/on the node.
I'm more of a subflow person, so this analogy may be wrong.

But in subflows, you can set user defined variables that are used by that node.
So that may cover your property1 and property2 question.

So I have never built a node as you are trying to do. As said: I used subflows.

Sorry I can't help more.

It depends how different the modes are. Normally we only use tabs if there are too many options to fit on a single properties page sensibly. For different modes we normally use a select drop-down that then shows or hides subsequent relevant fields. Eg see the delay node change between delay and rate limit modes of operation.

That looks like a great solution. Can you please point me to the node implementation? I could not find it in @node-red/node-red-nodes.

The delay node (and others) are here node-red/packages/node_modules/@node-red/nodes/core/function at master · node-red/node-red · GitHub
The key logic is in the oneditprepare function of the .html file eg line 262

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.