Skip to content

bug: setfocus with viewChild #21047

@indraraj26

Description

@indraraj26

Bug Report

Ionic version:

[x] 5.x

Current behavior:

It does not have setFocus method when you access ion-input element as ionInput;

  @ViewChild('testInput', {read: IonInput}) testInput: IonInput;

  
 ngAfterViewInit(): void {
   console.log((this.testInput as IonInput))
   console.log((this.testInput as IonInput).setFocus())
 }

output:

IonInput {z: {…}, el: {…}, ionInput: {…}, ionChange: {…}…}
el: r
ionBlur: Observable
ionChange: Observable
ionFocus: Observable
ionInput: Observable
z: NgZone

Expected behavior:

It should have setFocus() to invoke focus programmatically.

Steps to reproduce:

Related code:

https://stackblitz.com/edit/ionic-angular-v5-y2wscm?file=src%2Fapp%2Fapp.component.html

insert short code snippets here

Other information:

Ionic info:

5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions