{"action":"created","issue":{"url":"https://api.github.com/repos/paypal/downshift/issues/357","repository_url":"https://api.github.com/repos/paypal/downshift","labels_url":"https://api.github.com/repos/paypal/downshift/issues/357/labels{/name}","comments_url":"https://api.github.com/repos/paypal/downshift/issues/357/comments","events_url":"https://api.github.com/repos/paypal/downshift/issues/357/events","html_url":"https://github.com/paypal/downshift/issues/357","id":302189027,"number":357,"title":"Is there a way to disable item selection?","user":{"login":"cusxio","id":6487613,"avatar_url":"https://avatars0.githubusercontent.com/u/6487613?v=4","gravatar_id":"","url":"https://api.github.com/users/cusxio","html_url":"https://github.com/cusxio","followers_url":"https://api.github.com/users/cusxio/followers","following_url":"https://api.github.com/users/cusxio/following{/other_user}","gists_url":"https://api.github.com/users/cusxio/gists{/gist_id}","starred_url":"https://api.github.com/users/cusxio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cusxio/subscriptions","organizations_url":"https://api.github.com/users/cusxio/orgs","repos_url":"https://api.github.com/users/cusxio/repos","events_url":"https://api.github.com/users/cusxio/events{/privacy}","received_events_url":"https://api.github.com/users/cusxio/received_events","type":"User","site_admin":false},"labels":[{"id":654664868,"url":"https://api.github.com/repos/paypal/downshift/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":719545974,"url":"https://api.github.com/repos/paypal/downshift/labels/good%20first%20issue","name":"good first issue","color":"4b7caf","default":true},{"id":654664869,"url":"https://api.github.com/repos/paypal/downshift/labels/help%20wanted","name":"help wanted","color":"128A0C","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-03-05T06:48:31Z","updated_at":"2018-03-06T06:40:06Z","closed_at":null,"author_association":"NONE","body":"* `downshift` version: 1.28.0\r\n* `node` version:\r\n* `npm` (or `yarn`) version:\r\n\r\n**Problem description**:\r\n\r\nIs there a way to disable the selection of an item based on some conditionals from the dropdown so that `onSelect` or `onChanged` doesn't gets triggered?\r\n\r\n**Methods tried**:\r\n\r\nI've tried using `stateReducer`, however after pressing enter on an item that I want to disable, the dropdown loses focus and the keyboard arrow keys stops working.\r\n\r\n```js\r\nfunction stateReducer(state, changes) {\r\n  switch (changes.type) {\r\n    case Downshift.stateChangeTypes.keyDownEnter:\r\n    case Downshift.stateChangeTypes.clickItem: {\r\n\r\n     // Basically I want to disable the selection of certain items.\r\n     // something like event.preventDefault();\r\n      const isRegistered = selectedItem.isRegistered;\r\n\r\n      if (isRegistered) {\r\n        return {\r\n          ...changes,\r\n          selectedItem: null,\r\n          inputValue: state.inputValue,\r\n          isOpen: state.isOpen,\r\n          highlightedIndex: state.highlightedIndex,\r\n        };\r\n      }\r\n      return changes;\r\n    }\r\n    default:\r\n      return changes;\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/paypal/downshift/issues/comments/370679826","html_url":"https://github.com/paypal/downshift/issues/357#issuecomment-370679826","issue_url":"https://api.github.com/repos/paypal/downshift/issues/357","id":370679826,"user":{"login":"austintackaberry","id":29493001,"avatar_url":"https://avatars0.githubusercontent.com/u/29493001?v=4","gravatar_id":"","url":"https://api.github.com/users/austintackaberry","html_url":"https://github.com/austintackaberry","followers_url":"https://api.github.com/users/austintackaberry/followers","following_url":"https://api.github.com/users/austintackaberry/following{/other_user}","gists_url":"https://api.github.com/users/austintackaberry/gists{/gist_id}","starred_url":"https://api.github.com/users/austintackaberry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/austintackaberry/subscriptions","organizations_url":"https://api.github.com/users/austintackaberry/orgs","repos_url":"https://api.github.com/users/austintackaberry/repos","events_url":"https://api.github.com/users/austintackaberry/events{/privacy}","received_events_url":"https://api.github.com/users/austintackaberry/received_events","type":"User","site_admin":false},"created_at":"2018-03-06T06:40:06Z","updated_at":"2018-03-06T06:40:06Z","author_association":"COLLABORATOR","body":"Sounds good to me, I'd be happy to take this one on! Also, looks like the `disabled` feature isn't in the docs. I'd be happy to add that as well."}}
{"actor":{"display_login":"austintackaberry"}}