TextInput should handle null values.

We have worked on several forms with Fuse and a common issue that we have faced is that when using Observables mapped to real data, we repeatedly have to check for null / undefined and set it to “” so that the TextInput actually updates to an empty string.

Consider the following code:

<App>
    <JavaScript>
        var Observable = require("FuseJS/Observable");

        var textValue = Observable();

        setTimeout(function() {
            console.log("Resetting text.");
            textValue.value = null;
        }, 10000);

        textValue.onValueChanged(function(val) {
            console.log("Text value changed: " + val);
        })

        module.exports = {
            textValue: textValue
        }
    </JavaScript>

    <TextInput Value="{textValue}" Background="#DDD"/>
</App>

If the app is launched and a user starts typing, 10 seconds later, the model value will reset to null but the TextInput will ignore that change and keep the stale string around.

When using / reusing a form where the parameter sets the initial values, not all fields will always have values. (For example, a user with firstName, lastName, email and optional phoneNumber).

Because of the “null” value not being accepted by the TextInput, a previous user’s phone number will stick around even after a parameter change.

My suggestion is to make the TextInput binding to an Observable with a null value behave just like an empty string. This would be similar functionality to Angular two-way binding, and I don’t believe such a change will negatively affect existing users or apps.