Skip to content

refactor(chat-messages): use CdkTextareaAutosize for chat input#2112

Open
chintankavathia wants to merge 1 commit into
mainfrom
refactor/ai/chat-input/textarea-auto-size
Open

refactor(chat-messages): use CdkTextareaAutosize for chat input#2112
chintankavathia wants to merge 1 commit into
mainfrom
refactor/ai/chat-input/textarea-auto-size

Conversation

@chintankavathia

@chintankavathia chintankavathia commented May 29, 2026

Copy link
Copy Markdown
Member

Replace the hand-rolled textarea auto-resize logic in SiChatInputComponent with Angular CDK's CdkTextareaAutosize directive (cdkAutosizeMinRows="1", cdkAutosizeMaxRows="8"). The 30vh viewport cap is preserved via CSS (max-block-size + overflow-y: auto) instead of JS.

Removes setTextareaHeight/adjustTextareaHeight and the (input) handler; behavior (min 1 row, max 8 rows, capped at 30% viewport) is unchanged.


Documentation.
Examples.
Dashboards Demo.
Playwright report.

Coverage Reports:

Code Coverage

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the chat input component to use Angular CDK's CdkTextareaAutosize directive for dynamic height adjustment, successfully removing custom height calculation logic. Feedback highlights a potential issue where the CDK directive's inline overflow-y: hidden style could prevent scrolling if the 30vh CSS height limit is reached before the 8-row limit; using overflow-y: auto !important; is recommended to resolve this.

Comment thread projects/element-ng/chat-messages/si-chat-input.component.scss
Replace the hand-rolled textarea auto-resize logic in SiChatInputComponent
with Angular CDK's CdkTextareaAutosize directive (cdkAutosizeMinRows="1",
cdkAutosizeMaxRows="8"). The 30vh viewport cap is preserved via CSS
(max-block-size + overflow-y: auto) instead of JS.

Removes setTextareaHeight/adjustTextareaHeight and the (input) handler;
behavior (min 1 row, max 8 rows, capped at 30% viewport) is unchanged.
@chintankavathia chintankavathia force-pushed the refactor/ai/chat-input/textarea-auto-size branch from d1d59f5 to 9561d5d Compare June 3, 2026 05:04
@chintankavathia chintankavathia marked this pull request as ready for review June 3, 2026 05:19
@chintankavathia chintankavathia requested review from a team as code owners June 3, 2026 05:19

@spike-rabbit spike-rabbit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something seems to wrong. It now always has a scrollbar, even if the height is not exceeded

@chintankavathia

Copy link
Copy Markdown
Member Author

something seems to wrong. It now always has a scrollbar, even if the height is not exceeded

seems like specific to firefox with our special fonts. our fonts are not honoring actual line-heights so even when having line height 16px firefox considers fonts to require 17px height causing textarea to have 17px scrollHeight but cdk calculate height based on the line height.

@dr-itz

dr-itz commented Jun 10, 2026

Copy link
Copy Markdown
Member

something seems to wrong. It now always has a scrollbar, even if the height is not exceeded

seems like specific to firefox with our special fonts. our fonts are not honoring actual line-heights so even when having line height 16px firefox considers fonts to require 17px height causing textarea to have 17px scrollHeight but cdk calculate height based on the line height.

yeah...known issue. that's why we e.g. force the height in input here https://github.com/siemens/element/blob/main/projects/element-theme/src/styles/bootstrap/forms/_form-control.scss#L118
Note that the workaround is actually not specific to our font but comes from Bootstrap originally.
But forcing height is obviously not gonna work for a multi-line textarea.

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.

3 participants