typedInput custom node prompts an error

After node-red upgraded to the latest v3.1.10 version, typedInput custom node prompts an error, and double clicking on the node doesn't open the node configuration interface, does anyone know how to solve this problem? Thanks in advance!

Error cannot call methods on typedInput prior to initialization; attempted to call method 'validate'

Related configuration code:

    RED.nodes.registerType("current-state-switch", {
    ...
            statusData: {
                value: "",
                required: true,
                validate: RED.validators.typedInput("statusDataType"),
            },
            statusDataType: {
                value: "str",
            },
            // validate: {
            //     statusData: RED.validators.typedInput("statusDataType"),
            // },
        },
    ...

        oneditprepare: function () {
            $("#node-input-statusData").typedInput({
                default: "str",
                typeField: $("#node-input-statusDataType"),
                types: ["str", "num", "bool"],
            });
        },
    });
    ...

    <div class="form-row">
    ...
        <div
            class="red-ui-typedInput-container"
        >
            <input
                type="text"
                id="node-input-statusData"
                placeholder="Status Data"
            />
        </div>
        <input
            type="hidden"
            id="node-input-statusDataType"
            style="display: none;"
        />
    </div>

I think that validation runs before you open the panel but the typedInput is only set up when you open the panel. According to the docs, you don't need to add that validation anyway since it is done automatically.

https://nodered.org/docs/api/ui/typedInput/#methods-validate

After node-red upgraded to the latest v3.1.10 version, typedInput custom node prompts an error,

There were some fixes in this area in 3.1.10 - I will investigate if this has broken something as what you are doing should work.

fyi @GogoVega

I found the problem, class name "red-ui-typedInput-container "

tags commented out, custom typedInput node parameter configuration interface is normal, the new version of the class name changed?

@Angin you should not be using the red-ui-typedInput-container class at all - that is an internal class the TypedInput will apply itself.

1 Like

Ok, thanks a lot, I mainly wanted to have the judgement condition and the typedInput value on a single line, so that the style is a bit prettier.I've had no problems with the old version before.

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