From 6d41ab1c44058d17cd8494b48da0070cea6e7bde Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Tue, 3 Sep 2024 11:23:02 +0200 Subject: [PATCH] fix: add logs to autocomplete textarea --- .../autocomplete-textarea.component.ts | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) 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 7c0748f4..3fe8f4a4 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 @@ -200,6 +200,10 @@ export class AutocompleteTextareaComponent } if (changes.value && !this.value && this.messageInput) { this.messageInput.nativeElement.style.height = 'auto'; + this.chatClientService.chatClient.logger( + 'info', + '[Autocomplete textarea] Value reset, adjusting textarea height to auto' + ); this.updateMentionedUsersFromText(); } else if ( changes.value && @@ -207,6 +211,10 @@ export class AutocompleteTextareaComponent this.messageInput && this.isViewInited ) { + this.chatClientService.chatClient.logger( + 'info', + '[Autocomplete textarea] Value changed' + ); setTimeout(() => { if (this.messageInput.nativeElement.scrollHeight > 0) { this.adjustTextareaHeight(); @@ -217,6 +225,10 @@ export class AutocompleteTextareaComponent ngAfterViewInit(): void { this.isViewInited = true; + this.chatClientService.chatClient.logger( + 'info', + '[Autocomplete textarea] View inited' + ); if (this.messageInput.nativeElement.scrollHeight > 0) { this.adjustTextareaHeight(); } @@ -251,6 +263,10 @@ export class AutocompleteTextareaComponent inputChanged() { this.valueChange.emit(this.messageInput.nativeElement.value); + this.chatClientService.chatClient.logger( + 'info', + '[Autocomplete textarea] Input changed' + ); this.adjustTextareaHeight(); } @@ -267,8 +283,20 @@ export class AutocompleteTextareaComponent } private adjustTextareaHeight() { - this.messageInput.nativeElement.style.height = ''; - this.messageInput.nativeElement.style.height = `${this.messageInput.nativeElement.scrollHeight}px`; + const necessaryHeight = `${this.messageInput.nativeElement.scrollHeight}px`; + if (this.messageInput.nativeElement.style.height === necessaryHeight) { + this.chatClientService.chatClient.logger( + 'info', + `[Autocomplete textarea] No need to adjust textarea height` + ); + } else { + this.chatClientService.chatClient.logger( + 'info', + `[Autocomplete textarea] Adjusting textarea height to ${necessaryHeight}` + ); + this.messageInput.nativeElement.style.height = ''; + this.messageInput.nativeElement.style.height = necessaryHeight; + } } private transliterate(s: string) {