mirror of https://github.com/Chocobozzz/PeerTube
Comment textarea focus on init
parent
59651eee56
commit
eacf925ea6
|
@ -1,6 +1,6 @@
|
|||
<form novalidate [formGroup]="form" (ngSubmit)="formValidated()">
|
||||
<div class="form-group">
|
||||
<textarea placeholder="Add comment..." formControlName="text" [ngClass]="{ 'input-error': formErrors['text'] }">
|
||||
<textarea placeholder="Add comment..." formControlName="text" [ngClass]="{ 'input-error': formErrors['text'] }" #textarea>
|
||||
</textarea>
|
||||
<div *ngIf="formErrors.text" class="form-error">
|
||||
{{ formErrors.text }}
|
||||
|
|
|
@ -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<VideoCommentCreate>()
|
||||
|
||||
|
@ -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 () {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</div>
|
||||
|
||||
<my-video-comment-add
|
||||
*ngIf="isUserLoggedIn() && inReplyToCommentId === comment.id" [video]="video" [parentComment]="comment"
|
||||
*ngIf="isUserLoggedIn() && inReplyToCommentId === comment.id" [video]="video" [parentComment]="comment" [focusOnInit]="true"
|
||||
(commentCreated)="onCommentReplyCreated($event)"
|
||||
></my-video-comment-add>
|
||||
|
||||
|
|
Loading…
Reference in New Issue