react-tags icon indicating copy to clipboard operation
react-tags copied to clipboard

Can't turn off autofocus

Open kellyprogramsthings opened this issue 3 years ago • 3 comments
trafficstars

Even with autofocus={false} and autoFocus={true} on a different input, it always focuses on the tags component.

I suppose I'm supposed to be more technical here, but I don't know what else to include.

Simple example:

import React from "react";
import { WithContext as ReactTags } from 'react-tag-input';

const ReactTagsTwo = () => {
  return (
    <React.Fragment>
      <input
        value={""}
        autoFocus={true}
      />
      <input
        value={""}
        autoFocus={false}
      />
      <ReactTags 
        autoFocus={false}
      />
    </React.Fragment>
  )
}

export default ReactTagsTwo;

Please excuse my very clever naming scheme.

kellyprogramsthings avatar Feb 04 '22 20:02 kellyprogramsthings

@kellyprogramsthings the prop is autofocus, its not your fault, we should rename the prop to be semantically correct :p

ad1992 avatar Feb 09 '22 06:02 ad1992

We can share the fault, as if I had actually read it instead of assuming, I wouldn't have had a problem. But thank you!

kellyprogramsthings avatar Feb 09 '22 09:02 kellyprogramsthings

Thank you. autofocus should really be false on default

paulm17 avatar May 09 '23 13:05 paulm17

I have added a prop autoFocus and will be remove autofocus in 7.x - https://github.com/react-tags/react-tags/pull/951

As per turning off the autofocus, I think we should do that as this would improve A11y as well since there will be other important components in the webpage and redirecting focus to the tags might be distracting for screen reader users.

Closing this as this was resolved.

ad1992 avatar Apr 24 '24 07:04 ad1992