Fuse Community

TextInput cursour not moving when we change text from JS

Hi,

I am setting Phone number format in Text Input. While setting phone number format, a cursor is not moving with text changes so when I type new characters, they are adding between the text, not at last.

Check code:

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

        mobileNumber.onValueChanged(module, function (text) {
            var number = mobileNumber.value.replace(/[^\d]/g, '');
            if (number.length === 7 || number.length === 8) {
                number = number.replace(/(\d{3})(\d+)/, "$1-$2");
            } else if (number.length === 9) {
                number = number.replace(/(\d{3})(\d{3})(\d{3})/, "$1-$2-$3");
            } else if (number.length > 9) {
                number = number.replace(/(\d{3})(\d{3})(\d+)/, "($1) $2-$3");
            }
            if (number === mobileNumber.value) {
                return;
            }
            mobileNumber.value = number;
        });

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

    <StackPanel Alignment="Center" Width="80%">
        <TextInput PlaceholderText="(000) 000-0000" PlaceholderColor="#7E858C" Padding="7,7,10,7" Value="{mobileNumber}" CaretColor="#329af0" FontSize="19" TextColor="#000" InputHint="Phone">
        </TextInput>
        <Rectangle Height="1" Color="#0314226B"/>
    </StackPanel>

</App>

Please log issues like this on the open fuselibs repository instead of forums.

Thanks, will create issue on Github