react-otp-input icon indicating copy to clipboard operation
react-otp-input copied to clipboard

Improve accessibility

Open ajayns opened this issue 7 years ago • 12 comments

Ensure that we follow WAI-ARIA guidelines specifications and have the correct aria attributes.

ajayns avatar Jun 09 '18 07:06 ajayns

Hey @apollonian I would like to work on that. Can you provide a little more description about the issue and assign it to me ?

rahulmalhotra avatar Oct 02 '19 08:10 rahulmalhotra

Yes please @rahulmalhotra!

The component currently renders a number of input elements (specified via numInputs prop with the default being 4). While I believe these inputs can be navigated by keyboard, the component lacks any aria-* attributes for screen readers or other assistive tech. For e.g. I think it would be good if we add an aria-describedby or aria-label prop to the component which can be used incase a label is not associated to it.

Let me know if you have any other doubts. :)

apollonian avatar Oct 02 '19 10:10 apollonian

Thanks..!! I am working on the same :-)

rahulmalhotra avatar Oct 02 '19 12:10 rahulmalhotra

Hey @apollonian and @ajayns I am planning to add input value to aria-label and type of input to the aria-describedby like below:-

aria-label={value} aria-describedby={isInputNum ? 'number input' : 'alphabet input'}

Is there any specific value you want to suggest ?

rahulmalhotra avatar Oct 02 '19 16:10 rahulmalhotra

@rahulmalhotra aria-describedby wouldn't work the way you have commented. This attributes needs to refer to an id present somewhere in the markup.

example:

<button ... aria-describedby="nameHeleper">submit</button>
<p id="nameHelper">By clicking the submit button, you agree to share your info with us</p>

and with input fields aria-labelledby is more suitable which works the same as described above.

vikas-parashar avatar Oct 03 '19 06:10 vikas-parashar

I think in that case, adding an aria-label will be fine. Waiting for the confirmation on this @apollonian

rahulmalhotra avatar Oct 03 '19 06:10 rahulmalhotra

@rahulmalhotra Yep! Also, aria-label could be a prop that you pass to the component (in the snippet I see that it is value) and is applied to the wrapper. And we'll add aria-labelledby to inputs as @vikas-parashar mentioned. I think that would be a good approach.

apollonian avatar Oct 03 '19 06:10 apollonian

Got that. But is there any specific value that I should use for aria-label and aria-labelledby ? I am using {value} currently for aria-label and there's nothing I have thought yet for aria-labelledby

rahulmalhotra avatar Oct 03 '19 09:10 rahulmalhotra

@rahulmalhotra We'll add them as props for the component itself.

apollonian avatar Oct 03 '19 09:10 apollonian

Okay. Cool. I'll update that soon.

rahulmalhotra avatar Oct 03 '19 11:10 rahulmalhotra

I can take a look and add any aria-props, or fixes towards violations, will be using deque axe testing platform if you don't mind?

ericblancas23 avatar Oct 04 '20 21:10 ericblancas23

have added in some color contrasting in the pr as well as creating a landmark for a main. If possible, do you mind adding in the "hacktoberfest-accepted", if participating?, if so that'd be awesome. Hopefully this will help out!

https://github.com/devfolioco/react-otp-input/pull/219

ericblancas23 avatar Oct 04 '20 23:10 ericblancas23

We are now passing aria-label prop to the input component and since the input component is fully customizable now with v3, you can provide override the prop if needed

prateek3255 avatar Mar 25 '23 15:03 prateek3255