fregante/fit-textarea

Use `rows`

Open

#21 opened on Jul 22, 2022

 (0 comments) (1 reaction) (0 assignees)TypeScript (2 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (83 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

As suggested in https://github.com/fregante/fit-textarea/issues/17

Unlike now, fit-textarea should start being a little more stateful, like caching the line-height

  1. Use getComputedStyle($0).lineHeight to get the line height on first load
  2. If normal, estimate (with excess) and then detect the height change at the next rows increase
  3. if the scrollHeight is higher than the clientHeight, set the rows attribute to scrollHeight/lineHeight

This would fix https://github.com/fregante/fit-textarea/issues/17 permanently.

Note: v3 is deprecated and any work should start on top of v2

Contributor guide