From: Chocobozzz Date: Fri, 29 Dec 2017 08:18:00 +0000 (+0100) Subject: Comment textarea focus on init X-Git-Tag: v0.0.1-alpha~70 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=eacf925ea668ba48c30f4e8e3c117d8daaebfe77;p=github%2FChocobozzz%2FPeerTube.git Comment textarea focus on init --- diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html index 792053614..365fc8f6c 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html @@ -1,6 +1,6 @@
-
{{ formErrors.text }} diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts index d05232202..a6525987e 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' +import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' import { FormBuilder, FormGroup } from '@angular/forms' import { NotificationsService } from 'angular2-notifications' import { Observable } from 'rxjs/Observable' @@ -17,6 +17,7 @@ import { VideoCommentService } from './video-comment.service' export class VideoCommentAddComponent extends FormReactive implements OnInit { @Input() video: Video @Input() parentComment: VideoComment + @Input() focusOnInit = false @Output() commentCreated = new EventEmitter() @@ -28,6 +29,8 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { 'text': VIDEO_COMMENT_TEXT.MESSAGES } + @ViewChild('textarea') private textareaElement: ElementRef + constructor ( private formBuilder: FormBuilder, private notificationsService: NotificationsService, @@ -46,6 +49,10 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { ngOnInit () { this.buildForm() + + if (this.focusOnInit === true) { + this.textareaElement.nativeElement.focus() + } } formValidated () { diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.html b/client/src/app/videos/+video-watch/comment/video-comment.component.html index 9608a1033..ffaf722cd 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.html +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.html @@ -10,7 +10,7 @@