-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The id
prop will be required in future versions to make the component accessible for users of assistive technologies such as screen readers.
#456
Comments
You need to add an |
@ericgio , can I ask you more clarifications? You can give me an example. |
Hi @Angelk90, sure: <Typeahead
id="my-typeahead-id"
labelKey="name"
options={users}
placeholder="Search user..."
onChange={this.handleChangeTy('userSelect')}
/> It works like the |
The id prop doesn't actually get passed through to the input. It isn't in the list of props that are passed through: react-bootstrap-typeahead/src/Typeahead.react.js Lines 29 to 52 in 74fccbe
|
That's correct. The warning doesn't refer to the input's id; it refers to an id for the typeahead component that is ultimately applied to the menu and used for accessibility. If you need to pass an id to the input itself, you would do that via |
Why do we need to pass this ID through? The only reason I can think of is for linking the input with the dropdown, but a class name is already automatically generated for this. What am I missing? |
@cameron-martin: It's used for accessibility. |
I got that, but what're you meant to link to that ID externally (from outside the component)? |
@cameron-martin I'm sorry, but I don't understand your question. You don't need to "link" anything, you just need to provide the id and the accessibility stuff happens internally. |
But a random id is generated automatically to use internally, so why do I need to provide one? |
The randomly generated id is going away in favor of an explicit, user-defined one. That change is based on what I've seen to be common practice in other libraries, with react-bootstrap being one particularly relevant case. |
FYI, the above PR has now landed so should be available in the next version of React :) |
Version
"react-bootstrap-typeahead": "^3.4.5"
Steps to reproduce
The text was updated successfully, but these errors were encountered: