Bug With MaxLength in Text component

Hello Folks, just reporting a bug with MaxLength property of a Text component.

When we Change the MaxLength using i.e. WhileTrue or something similar… nothing happens:

follow the reproduction:

<App Background="#000">
    <JavaScript>
        var Observable = require('FuseJS/Observable');

        var isFull = Observable(false);
        var toggle = function () {
            isFull.value = !isFull.value;
        }

        module.exports = {
            isFull: isFull,
            toggle: toggle
        }
    </JavaScript>
    <Panel Color="#FFF" Padding="20">

        <Text ux:Name="detailsText"
            Value="[Click Me] Really Big text goes here... just to test the text truncation when we use MaxLenght... i think maybe a bug was found here..."
            Alignment="CenterLeft" TextWrapping="Wrap"
            MaxLength="30"/>
        <WhileTrue Value="{isFull}">
            <Change detailsText.MaxLength="2048" />
            <Change detailsText.Color="#FF0000" />
        </WhileTrue>
        <Clicked>
            <Callback Handler="{toggle}" />
        </Clicked>
    </Panel>

</App>

Fuse Version: Fuse version 0.36.1 (build 12010)
OS: OSX Sierra 10.12.4

Tks

Hi Diego,

and thanks for reporting. We have raised an internal ticket and someone will take a look at it shortly.

In the meantime, I would like to offer two potential workarounds for this:

  1. Use JavaScript to change the data-bound Observable value of the Text to show either smaller or larger amount of text.

  2. Have two Text elements in UX - one with the smaller MaxLength and the other with the big one - and toggle their visibility based on an Observable boolean.

Hope this helps! Will keep you posted on the status of the ticket.

Tks! Helped a lot.

I just workaround with option 1

Hi!

Setting a MaxLength limits the max length of the value set on a Text. So setting a value that is longer than the MaxLength will always truncate.

I Understood that… But I reporting because I think the correct behavior is to restore the truncated text if I change the MaxLength to a lesser value…

It’ll give us the ability to do great things…

Hi Diego,

by design, MaxLength on Text element makes very little sense, so no major changes in this area are to be expected. Note that MaxLength does make a lot of sense on TextInput, but there it plays a completely different role and will rarely need to change during run-time (and when it does, you will not have the same issue as here).

The recommended solutions then still are those I posted in my first reply.