Skip to content

Commit

Permalink
Merge pull request #636 from GetStream/textarea-logs
Browse files Browse the repository at this point in the history
fix: add debug logs to autocomplete textarea
  • Loading branch information
szuperaz authored Sep 3, 2024
2 parents 08d9bb3 + 7abda2d commit f6d6121
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,21 @@ 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 &&
this.value &&
this.messageInput &&
this.isViewInited
) {
this.chatClientService?.chatClient?.logger?.(
'info',
'[Autocomplete textarea] Value changed'
);
setTimeout(() => {
if (this.messageInput.nativeElement.scrollHeight > 0) {
this.adjustTextareaHeight();
Expand All @@ -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();
}
Expand Down Expand Up @@ -250,6 +262,10 @@ export class AutocompleteTextareaComponent
}

inputChanged() {
this.chatClientService?.chatClient?.logger?.(
'info',
'[Autocomplete textarea] Input changed'
);
this.valueChange.emit(this.messageInput.nativeElement.value);
this.adjustTextareaHeight();
}
Expand All @@ -267,6 +283,10 @@ export class AutocompleteTextareaComponent
}

private adjustTextareaHeight() {
this.chatClientService?.chatClient?.logger?.(
'info',
`[Autocomplete textarea] Textarea height set from ${this.messageInput.nativeElement.style.height} to ${this.messageInput.nativeElement.scrollHeight}px`
);
this.messageInput.nativeElement.style.height = '';
this.messageInput.nativeElement.style.height = `${this.messageInput.nativeElement.scrollHeight}px`;
}
Expand Down

0 comments on commit f6d6121

Please sign in to comment.