[BUG]Determine the length when the text width changes and set the fixed length

I am pleased that I can now change the length of the rectangle by changing the text in the text field. However, I have encountered a problem.

Scene:
A message bubble that adapts to the width when the length is less than 300, and when it is greater than or equal to 300, the width is fixed at 300.

Elements:
Text field, rectangle

Interaction process:
Input text into the text field, add an interaction to the text field “When text changes” to set the text of the rectangle as [[This.text]]. Then, add an interaction “When size changes” to the rectangle. Under the “size change” interaction, add a judgment: If “[[This.width]]” is greater than or equal to “300”, set the width of the current element to 300 without setting the height.

Result:
After the length exceeds 300, it still adapts to the length instead of being fixed at 300. I need the length to remain unchanged and only the height to be adjusted when it exceeds 300. I hope to find a solution or have other correct implementation methods. Thank you.

Hey @wenyd ,

It seems like the issue you’re encountering is that you want to be able to turn off “Fit Text Width” when the text widget reaches a certain width.

Unfortunately, there isn’t an interaction that directly targets this style setting. However, you can include two rectangles as a substitute–one with it turned on, and one turned off.

image image

With this setup, you can have one hidden and the other one shown, and depending on the size you can have them change visibility.

I have created this widget setup and attached the example file for your convenience.
Fit to Text Solution.rp (47.0 KB)

Under the text area you can see the interactions and the conditional logic I included. One thing to note is to ensure you’re using the correct local variable within your condition.

In the meantime, being able to change the Fit to Text setting with interactions is something that could be very useful, especially in a situation like this. I’ll submit this as a feature request for our product team to review.

Hope this solution works and if you have any questions please let us know