Last active
October 13, 2025 14:24
-
-
Save tukkek/156a240c75c55c0125a0aaa0fe76318e to your computer and use it in GitHub Desktop.
Module to automatically-resize text-area elements.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // no-longer needed after Fire-fox implements textarea{field-sizing:content;} | |
| function update(element){ | |
| let rows=element.value.split('\n').length | |
| if(rows<1) rows=1 | |
| element.setAttribute('rows',rows) | |
| } | |
| export function resize(element){ | |
| update(element) | |
| element.addEventListener('input',()=>update(element)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment