我需要循环浏览扩展的覆盖控件。展开覆盖后,我想循环浏览输入元素,直到覆盖折叠。我的代码工作到了一定程度,即一旦覆盖层可见,我的焦点就会设置到第一个输入元素并循环到最后一个“按钮”元素。
我的问题是我添加的代码以便我可以围绕扩展的覆盖进行循环没有按预期工作。
此代码片段最初将焦点设置为第一个输入元素
@ViewChild('focusShortCode', { static: true }) nameField: ElementRef;
public setFocus(isSet: boolean) {
if (isSet) {
this.nameField.nativeElement.focus();
}
}
此代码片段应该再次将焦点设置回第一个输入元素
public onBlur(isSet: boolean) {
if (isSet) {
this.nameField.nativeElement.focus();
}
}
问题是当调用“onBlur”时,我的焦点会跳转到展开的叠加层中的第二个输入元素
onblur 将焦点设置到“名称”元素而不是“短代码”元素
<div class="container">
<div class="layout-box" igxLayout igxLayoutJustify="end">
<div class="layout-box__el" >
<igx-input-group type="border" style="width: 200px;">
<input igxInput #focusShortCode name="shortCode" type="text" [value]="shortCode" />
<label igxLabel for="shortCode">{{shortCodePlaceHolder}}</label>
</igx-input-group>
</div>
<div class="layout-box__el">
<igx-input-group type="border" style="width: 200px;">
<input igxInput name="name" type="text" [value]="name" />
<label igxLabel for="name">{{namePlaceHolder}}</label>
</igx-input-group>
</div>
</div>
<div class="layout-box" igxLayout igxLayoutJustify="end" style="margin-top: -15px;">
<div class="layout-box__el">
<igx-input-group type="border" style="width: 200px;">
<input igxInput name="street1" type="text" [value]="street1" />
<label igxLabel for="street1">{{street1PlaceHolder}}</label>
</igx-input-group>
</div>
<div class="layout-box__el">
<igx-input-group type="border" style="width: 200px;">
<input igxInput name="street2" type="text" [value]="street2"/>
<label igxLabel for="street2">{{street2PlaceHolder}}</label>
</igx-input-group>
</div>
</div>
<div class="layout-box" igxLayout igxLayoutJustify="end" style="margin-top: -15px;">
<div class="layout-box__el">
<igx-input-group type="border" style="width: 200px;">
<input igxInput name="city" type="text" [value]="city"/>
<label igxLabel for="city">{{cityPlaceHolder}}</label>
</igx-input-group>
</div>
<div class="layout-box__el">
<igx-input-group type="border" style="width: 200px;">
<input igxInput name="country" type="text" [value]="county"/>
<label igxLabel for="country">{{countyPlaceHolder}}</label>
</igx-input-group>
</div>
</div>
<div class="layout-box" igxLayout igxLayoutJustify="end" style="margin-top: -15px;">
<div class="layout-box__el">
<igx-input-group type="border" style="width: 200px;">
<input igxInput name="postCode" type="text" [value]="postCode"/>
<label igxLabel for="postCode">{{postCodePlaceHolder}}</label>
</igx-input-group>
</div>
<div class="layout-box__el">
<igx-input-group type="border" style="float: right; width: 100px;" >
<input igxInput name="country" type="text" [value]="country" />
<label igxLabel for="country">{{countryCodePlaceHolder}}</label>
</igx-input-group>
</div>
<div>
<button class="igx-button--raised" #buttonElement igxButton (keydown.Tab)="onBlur(true)">Close</button>
</div>
</div>
</div>