]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+videos/+video-watch/comment/video-comment-add.component.ts
Correct break line display for re-draft comments
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-watch / comment / video-comment-add.component.ts
index 41edb35abfc5b087a5332a3b0c20ba08bad3783c..d746a614b4395510a87b326e754eb0cfd6dc7f4d 100644 (file)
@@ -2,7 +2,8 @@ import { Observable } from 'rxjs'
 import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'
 import { Router } from '@angular/router'
 import { Notifier, User } from '@app/core'
-import { FormReactive, FormValidatorService, VideoCommentValidatorsService } from '@app/shared/shared-forms'
+import { VIDEO_COMMENT_TEXT_VALIDATOR } from '@app/shared/form-validators/video-comment-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { Video } from '@app/shared/shared-main'
 import { VideoComment, VideoCommentService } from '@app/shared/shared-video-comment'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
@@ -33,11 +34,10 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private videoCommentValidatorsService: VideoCommentValidatorsService,
     private notifier: Notifier,
     private videoCommentService: VideoCommentService,
     private modalService: NgbModal,
-    private router: Router,
+    private router: Router
   ) {
     super()
   }
@@ -50,7 +50,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
 
   ngOnInit () {
     this.buildForm({
-      text: this.videoCommentValidatorsService.VIDEO_COMMENT_TEXT
+      text: VIDEO_COMMENT_TEXT_VALIDATOR
     })
 
     if (this.user) {
@@ -183,7 +183,11 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
         this.textareaElement.nativeElement.focus()
       }
 
+      // Scroll to textarea
       this.textareaElement.nativeElement.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' })
+
+      // Use the native textarea autosize according to the text's break lines
+      this.textareaElement.nativeElement.dispatchEvent(new Event('input'))
     })
 
     this.form.patchValue({ text })