-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: adds auto resize feature to textarea #10786
feat: adds auto resize feature to textarea #10786
Conversation
9012d60
to
ddc525d
Compare
ddc525d
to
9cf55ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't checked the implementation yet, and I thought it was using the new CSS field-sizing property.
The implementation of this PR has some issues. For example, it doesn't display a scroll-bar. Also, it requires an additional div and some CSS tricks.
I think we should use field-sizing
. It's a single line of code and is already supported by 73% of users. Firefox already gave a positive vote to the standard in September so it probably won't take that long. I didn't find anything specific about Safari.
244fd69
to
068a426
Compare
@GermanJablo Hey thanks for the feedback! Yea I was using the extra div and css tricks because For the scrollbar, unless it hits the height constraint there will be no scrollbar displayed, it's the default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, much better!
We also agree on not setting a pre-set max-height. In fact, we had the same discussion about the codeblock: #8209
The only detail I would fix in this PR is that if the user manually shrinks the textArea and it takes up less space than the content, the scrollbar should be visible (I don't see it right now).
The scrollbar is currently not visible on chrome also on the main branch, not sure why this style has been added? https://github.com/payloadcms/payload/blob/main/packages/ui/src/fields/Textarea/index.scss#L58-L60 I have removed for now and added |
Screen.Recording.2025-01-28.at.21.18.08.mov |
068a426
to
3500b00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I changed
overflow-y
fromscroll
toauto
, so that the scroll-bar is only visible if there is overflow. - reverted PR feat: let textarea grow based on value #1398. Back then
field-sizing
wasn't a thing and fortunately certain hacks aren't needed now.
For the record, I made sure that textareas are displayed correctly in dark and light mode, as well as error states. Also, the height behavior now follows the decision made in #8209.
Thanks a lot, @LimChorngUan !
Thanks a lot of the feedback and changes you made too! |
🚀 This is included in version v3.21.0 |
How do you get it to resize? |
Hey @openbayou, it should be automatic and no configuration needed since we used |
This PR introduces an auto resize feature for the
textarea
field.By default Payload
textarea
field will dynamically adjust its height based on its content.