i-like-robots / react-tag-autocomplete

⚛️ A simple, accessible, tagging component ready to drop into your React projects (new repo)
https://i-like-robots.github.io/react-tag-autocomplete/
ISC License
178 stars 12 forks source link

Added focused prop #64

Closed jpranays closed 8 months ago

jpranays commented 9 months ago

An optional prop focused, which keeps input auto-focused on the initial render

jpranays commented 8 months ago

Any update on this ?

i-like-robots commented 8 months ago

Thank you for your contribution @jpranays and thank you for your patience. Autofocus was a feature of the component for a long time but I removed it following advice that autofocus tended to create more confusing experiences for users of assistive devices, or as this site puts it:

Autofocus can be implemented in an accessible way, but it’s often unnecessary. Many developers use the autofocus attribute to compel their users to take a certain action — and that’s a bad idea.

You should only use autofocus when a component is unambiguously important, and when adding the attribute will improve experiences for all users (regardless of the technologies they use to access your website or app).

With this in mind I'm reluctant to encourage the pattern - and of course it is still possible to grab a reference to the component input and implement a hook as you have done should people be sure it's what they want to do.