JedWatson / JedWatson/react-select
Select is non-labellable
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
I'm still working on preparing a codesandbox for this; I don't yet know how to get it to load the React Testing Library, nor how to actually save a fork, and it looks like I might need to register an account there to actually save anything for any length of time.
Anyway, when I have a <label for="whatever"> pointed at a <Select id="whatever">, and I use React Testing Library's getByLabelText to find it, I get a message like:
TestingLibraryElementError: Found a label with the text of: /xg file:/i, however the element associated with this label (<div />) is non-labellable [https://html.spec.whatwg.org/multipage/forms.html#category-label]. If you really need to label a <div />, you can use aria-label or aria-labelledby instead.
Does React-Select really not let me label the control with a forward ID reference, and I need to use a reverse ID reference instead? Or is labeling the input via setting an inputId going to be sufficient to both let the user operate the select control and let the test code find the whole select control by label?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported Select, label for, inputId, and React Testing Library getByLabelText combination; the issue does not name a source file or test. Done means determining whether the control is correctly associated for users and tests, then documenting or implementing the supported labeling behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- accessibility, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100