ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
50.95k stars 13.52k forks source link

feat: Programmatically focus an ion-button #29919

Open mortifia opened 2 days ago

mortifia commented 2 days ago

Prerequisites

Describe the Feature Request

It would be really useful to programmatically focus an ion-button (without having two focus states on the same element at different levels).

References:

GitHub Issue MDN Web Docs on ShadowRoot.delegatesFocus Now, all browsers support delegatesFocus."

Describe the Use Case

avoid to config ion-button two times (on click and on keyup.enter)

Describe Preferred Solution

No response

Describe Alternatives

No response

Related Code

No response

Additional Information

No response

brandyscarney commented 1 day ago

Thanks for the issue! This can be done by calling setFocus on the ion-app: https://ionicframework.com/docs/api/app#programmatic-focus

Does this solution work for your use case?