# Bug With MaxLength in Text component 

**URL:** <https://forums.fusetools.com/t/bug-with-maxlength-in-text-component/2553>\
**Category:** Bug Reports\
**Created:** [May 2, 2017, 3:27pm UTC](https://forums.fusetools.com/t/bug-with-maxlength-in-text-component/2553 "2017-05-02T15:27:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diego\_Cubissimo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/diego_cubissimo/32/134_2.png) [@Diego\_Cubissimo](https://forums.fusetools.com/u/Diego_Cubissimo)\
**Post date:** [May 2, 2017, 3:27pm UTC](https://forums.fusetools.com/t/bug-with-maxlength-in-text-component/2553/1 "2017-05-02T15:27:18Z")

</div>

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:

```auto
<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

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [May 2, 2017, 3:46pm UTC](https://forums.fusetools.com/t/bug-with-maxlength-in-text-component/2553/2 "2017-05-02T15:46:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Diego\_Cubissimo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/diego_cubissimo/32/134_2.png) [@Diego\_Cubissimo](https://forums.fusetools.com/u/Diego_Cubissimo)\
**Post date:** [May 2, 2017, 3:49pm UTC](https://forums.fusetools.com/t/bug-with-maxlength-in-text-component/2553/3 "2017-05-02T15:49:25Z")

</div>

Tks! Helped a lot.

I just workaround with option `1`

---

<div class="post-metadata">

**Author:** ![Vegard\_Strand\_Lende](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/vegard_strand_lende/32/349_2.png) [@Vegard\_Strand\_Lende](https://forums.fusetools.com/u/Vegard_Strand_Lende)\
**Post date:** [May 3, 2017, 10:54am UTC](https://forums.fusetools.com/t/bug-with-maxlength-in-text-component/2553/4 "2017-05-03T10:54:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Diego\_Cubissimo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/diego_cubissimo/32/134_2.png) [@Diego\_Cubissimo](https://forums.fusetools.com/u/Diego_Cubissimo)\
**Post date:** [May 3, 2017, 11:39am UTC](https://forums.fusetools.com/t/bug-with-maxlength-in-text-component/2553/5 "2017-05-03T11:39:29Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [May 4, 2017, 10:02am UTC](https://forums.fusetools.com/t/bug-with-maxlength-in-text-component/2553/6 "2017-05-04T10:02:01Z")

</div>

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.
