tusen-ai / naive-ui

A Vue 3 Component Library. Fairly Complete. Theme Customizable. Uses TypeScript. Fast.
https://www.naiveui.com
MIT License
16.29k stars 1.68k forks source link

Accessibility for inputs #4598

Open djfuzzy opened 1 year ago

djfuzzy commented 1 year ago

This function solves the problem (这个功能解决的问题)

There currently doesn't appear to be a way to associate labels with inputs as recommended by W3C for accesibility: https://www.w3.org/WAI/tutorials/forms/labels/. This is so people using screen readers or voice assistants can properly identify inputs. A website using this framework would be difficult to use by people who are hard of seeing or have other disabilities.

Expected API (期望的 API)

<n-form-item label="Name" path="name">
  <n-input id="nameInput" v-model:value="form.name" type="text" />
</n-form-item>

Should generate something like the following:

<label for="nameInput" ...>Name</label>
...
<input type="text" id="nameInput" ...>

If the id is missing, a random, unique one should be automatically generated.

It should also be possible to use aria attributes like aria-label when there isn't an identifying element for the input.

<n-input id="nameInput" v-model:value="form.name" type="text" aria-label="Name" />
woodhull commented 1 year ago

It also makes it very difficult to use naive-ui with many test automation technologies.

kvii commented 1 year ago

The code below is works in my case, but it's a little bit ... boring.

<NFormItem label="label" path="field" :label-props="{ 'for': 'field' }">
    <NInput v-model:value="model.field" :input-props="{ autocomplete: 'off', id: 'field' }" />
</NFormItem>
tommed commented 10 months ago

There is a wider need for WCAG/WAI support in this UI. Here in the UK and also in the USA, there is legislation requiring systems to properly work with screen readers and keyboard shortcuts.

There seems to be almost no support for WCAG in these components. Is this something which would be considered? It's super important for us to allow any end-users with disabilities to use our systems fully, but this component library looks very very good - it puts us in a difficult place.

jahnli commented 8 months ago

This issue does not have any recent activity. If you are still experiencing similar problems, open a new error, including a minimal copy of the problem

tommed commented 8 months ago

Closing due to inactivity < fixing the ticket!

woodhull commented 8 months ago

It seems very unhelpful to close all of the accessibility tickets.

jahnli commented 8 months ago

At present, the problem has been submerged. In my opinion, only by re-opening a problem can more people see it and be willing to add it. If this problem is closed, I am very sorry and I will re-open it

djfuzzy commented 8 months ago

Accessibility should be a top priority for the maintainers of this library. It's absurd that a UI library in 2024 is not following even the basic of accessibility standards that have been around for a long time.

tommed commented 8 months ago

Tbh, @djfuzzy have you seen PrimeVue's WCAG support? It's really impressive. Given this library isn't likely to get all the basics anytime soon - you may want to check this out.

djfuzzy commented 8 months ago

@tommed I was actually thinking about that. I can't go live with my web app without accessibility so I was strongly considering another UI library, and PrimeVue was one of them. Thanks for the suggestion!