Skip to content

feat: provide setFocus interface on IonRadio, IonCheckbox, IonItem, and IonButton #21401

@triptate

Description

@triptate

Feature Request

Ionic version:

[x] 5.1.1

Describe the Feature Request

Currently only the IonInput, IonTextarea, and IonSearchbar components offer a setFocus interface for programmatically focusing the component. It was suggested in the Slack group that this was due to those components needing to bring up the mobile keyboard and there being no value to focusing other types of elements programmatically. However, on desktop/web there is value to managing focus, particularly for supporting custom keyboard accessibility features. In our case, we are trying to implement a searchable select component, and would like to be able to tab through the options using arrow keys. Without programmatic access to the select options (we are using IonRadio components), we cannot manage the focus.

Describe Preferred Solution

The IonRadio, IonCheckbox, IonItem, and IonButton components should have a setFocus interface available on their refs. Calling setFocus on the ref would apply focus to the native element wrapped by that component.

Describe Alternatives

Currently the only workaround we've come up with is to use native HTML elements in place of Ionic components, but doing so requires also implementing custom styles for the native elements.

Related Code

I think this is understandable without a code example, but let me know if any supporting code would be helpful to see.

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    a11yAccessibility related issuespackage: core@ionic/core packagetype: feature requesta new feature, enhancement, or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions