resize textarea with wire:stream
I'm trying to get the textarea to resize every time it updates with wire:stream so that the height is adjusted, but I can't get it to work. If I write it manually, it adjusts, but when it updates automatically, it doesn't. Any ideas?
9 Replies
This is my textarea
Maybe listen/observe changes on the textarea like this (it's an function called in the
x-data
):
It's from head, so it's maybe not working :/with this works perfectly, except that it doesn't continue all the way to the end of the viewport. That is, since the screen is larger, it can't be seen all the way to the bottom.:
Maybe using this function aside of the resize can help to scroll to bottom ?
I tried but it doesn't work
#textarea-container
is the component you want to scroll on the bottom of, right ?
Or you want to scroll continuously on the bottom of your textarea while streaming content ?I want to scroll continuously on the bottom of my textarea while streaming content
Allright
Here's a component I made with the same logic 🙂
Don't forget
textarea.scrollTop = textarea.scrollHeight;
in the autoResize funcion 😉I've been trying it out but the textarea starts to increase almost at the end of the viewport.
When it starts to increase the height gets lost at the end and can't be seen. Maybe I should scroll the page instead of the textarea... I have to try.
It works perfectly, I really wanted to get something that was not viable. Thank you very much for the help!