This particular component I'm working on has a hidden textarea by default :
<div class="action ui-g-2" (click)="toggleEditable()">edit</div>
<textarea [hidden]="!whyModel.inEdition" #myname id="textBox_{{whyModel.id}}" pInputTextarea focus="true" [(ngModel)]="whyModel.description"></textarea>
My goal is to make the textarea visible and automatically put focus on it when the user clicks on the "edit" div :
@ViewChild('myname') input: ElementRef;
...
private toggleEditable(): void {
this.whyModel.toggleEditable();
this.input.nativeElement.focus();
}
The visibility part seems to be functioning correctly, but the autofocus feature is not working as intended. Can anyone provide insight on what might be missing in my implementation?