Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dannycalleri opened this issue Oct 18, 2023 · 0 comments
Labels
breaking enhancement New feature or request

Comments

@dannycalleri
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant