Skip to content

The autofocus is applied to the first focusable child element by default #457

@dannycalleri

Description

@dannycalleri

By default, the autofocus is applied to the first focusable child of the element to which the modifier is attached to, as visible here: https://github.com/qonto/ember-autofocus-modifier/blob/master/ember-autofocus-modifier/src/modifiers/autofocus.js#L24

👉 Notice how selector === DEFAULT_SELECTOR by default: https://github.com/qonto/ember-autofocus-modifier/blob/master/ember-autofocus-modifier/src/modifiers/autofocus.js#L17

This beheavior isn't ideal, as we may want to check the element to which the autofocus modifier itself is attached to first.

Example

<details>
  <summary {{autofocus}}>Napoleon surname <input type="text" /></summary>
  <p>Bonaparte</p>
</details>

Current behavior

With the current implementation, the focus would go to the input element, while focusing the summary element could be exactly what the user expected.

Expected behavior

The summary element should be the one focused, leaving the input unfocused.

Any thoughts about this?

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