Doist / reactist

Open source React components made with ❤️ by Doist
http://doist.github.io/reactist
MIT License
248 stars 22 forks source link

TextArea with autoExpand={true} expands horizontally when typing long text without spaces #776

Closed gnapse closed 1 year ago

gnapse commented 1 year ago

🐛 Bug report

Current behavior

In a TextArea with autoExpand enabled, when typing a long text without a space in it, the text area can become wider than intended.

Admittedly, it is not common for anyone to type long texts without any space in it. While at the same time, it is not exactly a disruptive behavior that the text area expand. Usability is not really affected. So this is a nice-to-have.

Steps to reproduce the bug

Visit the TextArea autoExpand story in storybook and start typing in the textarea at the top, the one that has a label saying that it has auto-expand enabled.

Expected behavior

Ideally we could make the text wrap, even if not at a word boundary, and have the text area width to be kept no matter what.

Possible solutions

I quickly tried enforcing the textarea's width by using combinations of width: 100%, max-width: 100%, overflow, etc. No luck so far.

Reference

Reported by @engfragui here.

MahirMahdi commented 1 year ago

But here the text area is working just fine. Please let me know if this is what you're talking. Screenshot 2023-06-04 113106

gnapse commented 1 year ago

Please, go to this storybook story and start typing in a text area at the top (the one that says it has auto-expand enabled). You should be able to reproduce:

CleanShot 2023-06-05 at 08 20 31@2x

I have updated the issue title and description to make this more clear. It was not as clear before.

MahirMahdi commented 1 year ago

Please, go to this storybook story and start typing in a text area at the top (the one that says it has auto-expand enabled). You should be able to reproduce:

CleanShot 2023-06-05 at 08 20 31@2x

I have updated the issue title and description to make this more clear. It was not as clear before.

I think there's something wrong with the last build. The styles are not applied to the storybook. Screenshot 2023-06-07 101857

MahirMahdi commented 1 year ago

@gnapse I believe I fixed it. overflow-wrap by default is break-word that's why it was expanding horizontally when typing text without spaces. When I changed it to anywhere, it stopped expanding.

Screenshot 2023-06-17 112717

gnapse commented 1 year ago

@MahirMahdi can you open a pull request with the proposed change?

MahirMahdi commented 1 year ago

@MahirMahdi can you open a pull request with the proposed change?

Yes, no problem. On it.