useTextField: Why does it have both id and aria-labelledby attributes? #3362
Unanswered
sandrina-p
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hey, so I don't believe we "need" both. However, it doesn't hurt anything that I'm aware of, and it allows us to use the same code to label both inputs and non-inputs. It might be an error in RTL/Jest because of NVDA or TalkBack, which I don't have access to right now to verify. Is it causing any issues for you? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there,
While reading the
useTextField
docs, it says:Considering a normal input (with a visible label), why do we need both
for
andaria-labelledby
attributes? Check the screenshot blow:In the Accessibility tree (and using Voice Over as Screen Reader), it seems like
for
is enough to provide a name to the input.So my 1st question: Is there any special case / exception where
for
is not enough / not supported?Additionally, I noticed you use both
jest
andreact-testing-library
to test your components, so may I ask a 2º question?When testing a label/input on my app using only
for
, the test fails with the following error:I wonder... is this error happening for the reason you use both attributes?
Thank you 🙇
Beta Was this translation helpful? Give feedback.
All reactions