Skip to content

Preserve autofocus attribute or add a shouldFocus option #857

@adrienpoly

Description

@adrienpoly

Is your feature request related to a problem? Please describe.
Unless I am mistaken when an input field has an autofocus attribute, Choices does not autofocus to this field. Probably because the autofocus remains on the hidden field

Describe the solution you'd like
I see two options

  1. detect the autofocus attribute and forward it to the choices input
  2. add a new option shouldFocus

Describe alternatives you've considered
Currently, I have a workaround using a callback in callbackOnInit

callbackOnInit: function () {
    this.input.focus()
}

This is a simpler version of what I am using since typically I can have multiple fields on my page with only one being autofocused. So there is a need for additional logic. This is where having this as an option or directly compatible with the autofocus attribute would be very nice

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions