diff --git a/frontend/src/app/ui/annotations/annotation-dialog-component/annotation-dialog.component.html b/frontend/src/app/ui/annotations/annotation-dialog-component/annotation-dialog.component.html index 0f4def83c..91a6496fe 100644 --- a/frontend/src/app/ui/annotations/annotation-dialog-component/annotation-dialog.component.html +++ b/frontend/src/app/ui/annotations/annotation-dialog-component/annotation-dialog.component.html @@ -29,7 +29,7 @@
{{'ANNOTATION-DIALOG.THREADS.NEW-THREAD' | translate}} - + {{threadFormGroup.get('text').getError('backendError')?.message}} {{'COMMONS.VALIDATION.REQUIRED' | translate}} @@ -156,7 +156,7 @@
{{'ANNOTATION-DIALOG.THREADS.REPLY' | translate}} - +
diff --git a/frontend/src/common/forms/common-forms.module.ts b/frontend/src/common/forms/common-forms.module.ts index 2176f6efd..460319e25 100644 --- a/frontend/src/common/forms/common-forms.module.ts +++ b/frontend/src/common/forms/common-forms.module.ts @@ -3,6 +3,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { PendingChangesGuard } from '@common/forms/pending-form-changes/pending-form-changes-guard.service'; import { FormService } from './form-service'; import { ReactiveAsteriskDirective } from './reactive-asterisk-directive'; +import { TextareaAutoresizeDirective } from './textarea-autoresize-directive'; @NgModule({ imports: [ @@ -11,16 +12,19 @@ import { ReactiveAsteriskDirective } from './reactive-asterisk-directive'; ], declarations:[ ReactiveAsteriskDirective, + TextareaAutoresizeDirective ], exports: [ FormsModule, ReactiveFormsModule, ReactiveAsteriskDirective, + TextareaAutoresizeDirective ], providers: [ FormService, PendingChangesGuard, ReactiveAsteriskDirective, + TextareaAutoresizeDirective ] }) export class CommonFormsModule { } diff --git a/frontend/src/common/forms/textarea-autoresize-directive.ts b/frontend/src/common/forms/textarea-autoresize-directive.ts new file mode 100644 index 000000000..592a28b1b --- /dev/null +++ b/frontend/src/common/forms/textarea-autoresize-directive.ts @@ -0,0 +1,26 @@ + +import { Directive, ElementRef, HostListener, OnInit } from '@angular/core'; + +@Directive({ + selector: '[appTextareaAutoresize]' +}) +export class TextareaAutoresizeDirective implements OnInit { + + constructor(private elementRef: ElementRef) { } + + @HostListener(':input') + onInput() { + this.resize(); + } + + ngOnInit() { + if (this.elementRef.nativeElement.scrollHeight) { + setTimeout(() => this.resize()); + } + } + + resize() { + this.elementRef.nativeElement.style.height = '0'; + this.elementRef.nativeElement.style.height = this.elementRef.nativeElement.scrollHeight + 'px'; + } +} \ No newline at end of file