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()">
|
<form novalidate [formGroup]="form" (ngSubmit)="formValidated()">
|
||||||
<div class="form-group">
|
<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>
|
</textarea>
|
||||||
<div *ngIf="formErrors.text" class="form-error">
|
<div *ngIf="formErrors.text" class="form-error">
|
||||||
{{ formErrors.text }}
|
{{ 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 { FormBuilder, FormGroup } from '@angular/forms'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import { Observable } from 'rxjs/Observable'
|
import { Observable } from 'rxjs/Observable'
|
||||||
|
@ -17,6 +17,7 @@ import { VideoCommentService } from './video-comment.service'
|
||||||
export class VideoCommentAddComponent extends FormReactive implements OnInit {
|
export class VideoCommentAddComponent extends FormReactive implements OnInit {
|
||||||
@Input() video: Video
|
@Input() video: Video
|
||||||
@Input() parentComment: VideoComment
|
@Input() parentComment: VideoComment
|
||||||
|
@Input() focusOnInit = false
|
||||||
|
|
||||||
@Output() commentCreated = new EventEmitter<VideoCommentCreate>()
|
@Output() commentCreated = new EventEmitter<VideoCommentCreate>()
|
||||||
|
|
||||||
|
@ -28,6 +29,8 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit {
|
||||||
'text': VIDEO_COMMENT_TEXT.MESSAGES
|
'text': VIDEO_COMMENT_TEXT.MESSAGES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ViewChild('textarea') private textareaElement: ElementRef
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private notificationsService: NotificationsService,
|
private notificationsService: NotificationsService,
|
||||||
|
@ -46,6 +49,10 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit {
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.buildForm()
|
this.buildForm()
|
||||||
|
|
||||||
|
if (this.focusOnInit === true) {
|
||||||
|
this.textareaElement.nativeElement.focus()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
formValidated () {
|
formValidated () {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<my-video-comment-add
|
<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)"
|
(commentCreated)="onCommentReplyCreated($event)"
|
||||||
></my-video-comment-add>
|
></my-video-comment-add>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue