Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert textarea changes #635

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { debounceTime } from 'rxjs/operators';
import { TransliterationService } from '../../transliteration.service';
import { EmojiInputService } from '../emoji-input.service';
import { CustomTemplatesService } from '../../custom-templates.service';
import { ThemeService } from '../../theme.service';

/**
* The `AutocompleteTextarea` component is used by the [`MessageInput`](./MessageInputComponent.mdx) component to display the input HTML element where users can type their message.
Expand Down Expand Up @@ -132,6 +133,7 @@ export class AutocompleteTextareaComponent
private transliterationService: TransliterationService,
private emojiInputService: EmojiInputService,
private customTemplatesService: CustomTemplatesService,
private themeService: ThemeService,
private cdRef: ChangeDetectorRef
) {
this.searchTerm$.pipe(debounceTime(300)).subscribe((searchTerm) => {
Expand Down Expand Up @@ -198,21 +200,13 @@ 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 @@ -223,10 +217,6 @@ 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 @@ -261,10 +251,6 @@ export class AutocompleteTextareaComponent

inputChanged() {
this.valueChange.emit(this.messageInput.nativeElement.value);
this.chatClientService?.chatClient?.logger?.(
'info',
'[Autocomplete textarea] Input changed'
);
this.adjustTextareaHeight();
}

Expand All @@ -281,20 +267,8 @@ export class AutocompleteTextareaComponent
}

private adjustTextareaHeight() {
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;
}
this.messageInput.nativeElement.style.height = '';
this.messageInput.nativeElement.style.height = `${this.messageInput.nativeElement.scrollHeight}px`;
}

private transliterate(s: string) {
Expand Down
Loading