Alert should auto focus first input
Prompts don’t auto focus first input
That should be a setting. Otherwise there will always be a software keyboard popup on mobile platforms.
Not that easy, since element.focus() is noop if it's not coming from an user interaction.
There might be challenges if running on a mobile device (due to keyboard popup) but it seems like you would always want to set focus on a desktop web page. Most web apps (including GitHub) set input focus when you click on buttons that lead to data entry. It seems very awkward to click on a button, have an alert displayed to enter a value, and still have to click in the input before entering the value.
Hoping this feature is coming to Ionic 6 ! I am in need of this as well
Any updates on this? Doesn't seem this feature made it into v6.
you can resolve it like this:
const alert = await this.alertCtrl.create(
{
header: "Motivo!",
message: 'Descreva um motivo para <strong>rejeição</strong>!',
inputs: [
{
name: 'comentario',
id: 'comentario',
type: 'textarea',
placeholder: 'Descreva um motivo'
}
],
buttons: [
{
text: 'Cancelar',
id: 'confirm-button',
handler: async (data: object) => {
resolve(false)
}
},
{
text: 'OK',
id: 'confirm-button',
handler: async (data: object) => {
resolve(data)
}
},
]
})
await alert.present()
const comentario :HTMLElement = document.querySelector("#comentario");
comentario.focus();