Skip to content
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(textarea): Added autosize with vueUse useTextareaAutosize #37

Closed
wants to merge 6 commits into from

Conversation

ManUtopiK
Copy link
Contributor

No description provided.

@jd-solanki
Copy link
Owner

Hi,

Thanks for the PR. This is really useful ❤️

I reviewed it in time I get and found that the initial value of v-model doesn't bind it however we can do this using:

const { textarea, input } = useTextareaAutosize({
  input: props.modelValue,
})

However, the main problem is we don't have just textarea. Our border styles are from its parent wrapper and scrollHeight should get calculated from textarea element.

I tried updating your PR but I think we need a few changes in VueUse that allows us to pass two separate elements just like we have. Styling element (out input wrapper) & actual textarea our textarea in ATextarea component.


To access the input wrapper from ATextarea I will expose it in the next commit. Moreover to access that wrapper useTextareaAutosize should be used in onMounted hook (to access baseInput.value.refInputWrapper). Once we use useTextareaAutosize it will bring back onInput & value usage on ATextarea.

Hence, there's some work we need to do on VueUse side if they approve and later on we need to update this PR.

I will create new PR/issue tomorrow on VueUse regarding this.

Thanks :)

@ManUtopiK
Copy link
Contributor Author

ManUtopiK commented Oct 9, 2022

I found that the initial value of v-model doesn't bind it

I didn't see that!
Using watch argument of useTextareaAutosize do the job!

@ManUtopiK
Copy link
Contributor Author

ManUtopiK commented Oct 9, 2022

I added the ability to limit height.
I'm not sure assigning a number to autoresize is a good choice. Maybe we can add a maxHeight prop instead.

Also, I found an issue with height prop. min-h-32 overwrite height if the value is lower than h-32.
min-h-32 should be removed if height is defined.
:autosize=10 works if min-h-32 is removed.
Maybe I can fix this issue in this pull request?

Furthermore, mixing pixel value and class value for height and autosize is not straightforward.
I don't know how to deal with that...

@jd-solanki
Copy link
Owner

autosize shouldn't accept number, textarea should update its height according to content just like demo in VueUse.

Let me create a PR in VueUse and will look into this further. Can you please revert back the previous commit as that was not needed and there is some typo/weird code?

Screenshot 2022-10-11 at 3 05 44 PM

@husayt
Copy link

husayt commented Mar 30, 2023

Hi, can this now be merged since the referenced issue in vueuse has been resolved.

@jd-solanki
Copy link
Owner

Yes, I noticed that and added it to the project board 😇

Just give me some time to update the project board.

@jd-solanki jd-solanki closed this in ee27a06 Apr 8, 2023
@jd-solanki
Copy link
Owner

Hi @ManUtopiK

Thanks so much for your efforts. We now have SFC instead of TSX so have to do it in a separate commit.

Thanks for your contribution 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants