Skip to content

Commit

Permalink
adjust textarea height for core/js
Browse files Browse the repository at this point in the history
  • Loading branch information
somebodyawesome-dev committed Jun 30, 2024
1 parent 19ee791 commit f0bed43
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/shared/src/components/Composer/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ export const createComposerDom: DomCreator<ComposerProps> = (props) => {
element.classList.add(className);

const textarea = document.createElement('textarea');

textarea.placeholder = props.placeholder ?? '';
textarea.value = props.message ?? '';

const adjustHeight = () => {
textarea.style.height = 'auto'; // Reset height
textarea.style.height = `${textarea.scrollHeight}px`; // Set new height based on content
};
textarea.addEventListener('input',adjustHeight);
if (props.autoFocus) {
textarea.autofocus = true;
}
Expand Down

0 comments on commit f0bed43

Please sign in to comment.