-
Notifications
You must be signed in to change notification settings - Fork 933
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
Disabled items can be selected by pressing enter #434
Comments
Thanks for the report @aknaus! So your suggested solution wont work I'm afraid because we have no control over the So we could change this: To this: selectItemAtIndex = (itemIndex, otherStateToSet, cb) => {
const item = this.items[itemIndex]
const itemNode = getItemNodeFromIndex(itemIndex)
if (item == null || (itemNode && itemNode.hasAttribute('disabled')) {
return
}
this.selectItem(item, otherStateToSet, cb)
} I'm pretty sure that'll work. If someone would like to make a PR for that with tests that'd be super! Thanks a bunch! |
Actually, this could preclude someone who wanted to force selection of a disabled item programatically... Perhaps we should put that logic right in the event handler here: Another thought... How is the highlighted item getting set to a disabled item? That shouldn't be possible. If it is then that's probably a bug. The highlighted index should probably skip disabled items don't you think? |
You are right @kentcdodds it should be handled in the event handler. However, I think it should be possible to focus disabled elements in order to aid people who are using screen readers. If I may, I would create a PR to resolve it? |
That sounds fine. Thanks! |
…hift-js#436) * disabled items cannot be selected * updated react-test-renderer and react-testing-library * added test for checking selection behaviour of disabled items * removed comment, used fireEvent instead of Simulate
downshift
version: 1.7.2node
version: 8.8.1npm
(oryarn
) version: 1.2.1Problem description:
At the moment it is possible to select a disabled item by pressing enter although selection by click is disabled. Personally, I think it should not be possible to select a disabled item (at least not for the user).
Suggested solution:
Since the event handler is not registered on the button and not on the item (like the onClick handler), we cannot just disable it. The easiest solution I can think of is checking the disabled prop before selecting an item. However, I do not have the required knowledge of your code to predict possible side effects of this change.
The text was updated successfully, but these errors were encountered: