From 42fcdd65ffb8019bfc5b70879cfdd98d42af799e Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Wed, 4 Sep 2024 14:45:56 +0200 Subject: [PATCH] fix: textarea height with multiline placeholder --- .../autocomplete-textarea.component.spec.ts | 2 +- .../autocomplete-textarea/autocomplete-textarea.component.ts | 2 +- .../src/lib/message-input/textarea/textarea.component.spec.ts | 2 +- .../src/lib/message-input/textarea/textarea.component.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/stream-chat-angular/src/lib/message-input/autocomplete-textarea/autocomplete-textarea.component.spec.ts b/projects/stream-chat-angular/src/lib/message-input/autocomplete-textarea/autocomplete-textarea.component.spec.ts index c7461d1d..eca0b211 100644 --- a/projects/stream-chat-angular/src/lib/message-input/autocomplete-textarea/autocomplete-textarea.component.spec.ts +++ b/projects/stream-chat-angular/src/lib/message-input/autocomplete-textarea/autocomplete-textarea.component.spec.ts @@ -473,7 +473,7 @@ describe('AutocompleteTextareaComponent', () => { it('should set initial height of the textarea based on value received', () => { const textarea = queryTextarea(); - textarea!.value = 'This is my \n multiline message'; + component.value = 'This is my \n multiline message'; component.ngAfterViewInit(); fixture.detectChanges(); diff --git a/projects/stream-chat-angular/src/lib/message-input/autocomplete-textarea/autocomplete-textarea.component.ts b/projects/stream-chat-angular/src/lib/message-input/autocomplete-textarea/autocomplete-textarea.component.ts index d8de3651..62c7df91 100644 --- a/projects/stream-chat-angular/src/lib/message-input/autocomplete-textarea/autocomplete-textarea.component.ts +++ b/projects/stream-chat-angular/src/lib/message-input/autocomplete-textarea/autocomplete-textarea.component.ts @@ -208,7 +208,7 @@ export class AutocompleteTextareaComponent 'info', '[Autocomplete textarea] View inited' ); - if (this.messageInput.nativeElement.scrollHeight > 0) { + if (this.messageInput.nativeElement.scrollHeight > 0 && this.value) { this.adjustTextareaHeight(); } } diff --git a/projects/stream-chat-angular/src/lib/message-input/textarea/textarea.component.spec.ts b/projects/stream-chat-angular/src/lib/message-input/textarea/textarea.component.spec.ts index 0fcfd50a..c753e699 100644 --- a/projects/stream-chat-angular/src/lib/message-input/textarea/textarea.component.spec.ts +++ b/projects/stream-chat-angular/src/lib/message-input/textarea/textarea.component.spec.ts @@ -163,7 +163,7 @@ describe('TextareaComponent', () => { it('should set initial height of the textarea based on value received', () => { const textarea = queryTextarea(); - textarea!.value = 'This is my \n multiline message'; + component.value = 'This is my \n multiline message'; component.ngAfterViewInit(); fixture.detectChanges(); diff --git a/projects/stream-chat-angular/src/lib/message-input/textarea/textarea.component.ts b/projects/stream-chat-angular/src/lib/message-input/textarea/textarea.component.ts index 8243da7b..30e15803 100644 --- a/projects/stream-chat-angular/src/lib/message-input/textarea/textarea.component.ts +++ b/projects/stream-chat-angular/src/lib/message-input/textarea/textarea.component.ts @@ -81,7 +81,7 @@ export class TextareaComponent } ngAfterViewInit(): void { - if (this.messageInput.nativeElement.scrollHeight > 0) { + if (this.messageInput.nativeElement.scrollHeight > 0 && this.value) { this.adjustTextareaHeight(); } }