I've created a component to display a simple modal dialog with dynamic inputs. This is an example of how it looks like:
Internally, it uses a PrimeNG dialog, and the input controls are created dynamically from an array received in a @Input property. This is the form I've created:
<form novalidate [formGroup]="formModel">
<ng-container *ngFor="let field of dialogData.formControls; let i=index">
<!-- Input field -->
<div *ngIf="field.type != 'hidden' && field.type != 'button' && field.type != 'separator'">
<div class="ui-inputgroup">
<span class="ui-float-label">
<!-- Input control -->
<input *ngIf="field.type != 'textarea' && field.type != 'hidden'" pInputText
[type]="field.type" [formControlName]="field.name" [name]="field.name"
(keyup.enter)="checkDialog()" (keyup.esc)="cancelDialog()" [tabindex]="i">
<textarea pInputTextarea *ngIf="field.type == 'textarea'" [formControlName]="field.name" [name]="field.name" rows="3" #inputField [tabindex]="i"></textarea>
<label [for]="field.name">
<i [ngClass]="field.icon"></i>
{{ field.label }}
</label>
</span>
</div>
<p class="fwc-error" [hidden]="formModel.get(field.name).valid || formModel.get(field.name).pristine">{{ 'ITEM_PANEL.ERRORS.FIELD_EMPTY' | translate }}</p>
</div>
<!-- Separator -->
<div class="ui-g-12" *ngIf="field.type == 'separator'"></div>
<!-- Hidden field -->
<input *ngIf="field.type == 'hidden'" type="hidden" [formControlName]="field.name" [name]="field.name">
</ng-container>
</form>
It's working fine, but I've realized that, when opened from an existing dialog, like the example above, I can't move between controls with the TAB key. When I open the dialog straight from the main menu, for instance, I can use the TAB without any problem.
What could the cause?
Thanks!
