MCPcopy Create free account
hub / github.com/angular/examples / onInput

Method onInput

dynamic-sdui-app/src/app/chat/chat.component.ts:212–227  ·  view source on GitHub ↗
(event: Event)

Source from the content-addressed store, hash-verified

210 }
211
212 onInput(event: Event): void {
213 const textarea = event.target as HTMLTextAreaElement;
214 textarea.style.height = 'auto'; // Reset height to calculate new scrollHeight
215
216 const computedStyle = getComputedStyle(textarea);
217 const lineHeight = parseFloat(computedStyle.lineHeight);
218 const maxHeight = lineHeight * 5;
219
220 const newHeight = Math.min(textarea.scrollHeight, maxHeight);
221 textarea.style.height = `${newHeight}px`;
222
223 // Ensure it scrolls to the bottom if maxHeight is reached
224 if (textarea.scrollHeight > maxHeight) {
225 textarea.scrollTop = textarea.scrollHeight;
226 }
227 }
228}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected