{"action":"created","comment":{"url":"https://api.github.com/repos/paypal/downshift/pulls/comments/170741664","pull_request_review_id":99474216,"id":170741664,"diff_hunk":"@@ -502,7 +506,7 @@ class Downshift extends Component {\n     },\n \n     Enter(event) {\n-      if (this.getState().isOpen) {\n+      if (this.isOpen) {","path":"src/downshift.js","position":37,"original_position":37,"commit_id":"4a70590ee4213f26e0c92776e8346471e4baa39f","original_commit_id":"03d51c04a24ac866c889a7f5402959f1f841a502","user":{"login":"kentcdodds","id":1500684,"avatar_url":"https://avatars0.githubusercontent.com/u/1500684?v=4","gravatar_id":"","url":"https://api.github.com/users/kentcdodds","html_url":"https://github.com/kentcdodds","followers_url":"https://api.github.com/users/kentcdodds/followers","following_url":"https://api.github.com/users/kentcdodds/following{/other_user}","gists_url":"https://api.github.com/users/kentcdodds/gists{/gist_id}","starred_url":"https://api.github.com/users/kentcdodds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentcdodds/subscriptions","organizations_url":"https://api.github.com/users/kentcdodds/orgs","repos_url":"https://api.github.com/users/kentcdodds/repos","events_url":"https://api.github.com/users/kentcdodds/events{/privacy}","received_events_url":"https://api.github.com/users/kentcdodds/received_events","type":"User","site_admin":false},"body":"I totally forgot that we were doing `.call(this.getStateAndHelpers(), event)` and thought we were doing `.call(this, event)`. So your changes make total sense.\r\n\r\nI'm thinking that I'd like to change the implementation slightly though. Could we do this instead?\r\n\r\n```javascript\r\nhandler(event, this.getStateAndHelpers())\r\n```\r\n\r\nIt doesn't resemble a true event handler anymore (because those only receive a single argument), but I think it makes more sense than using `this`. People could give things a much better name:\r\n\r\n```javascript\r\nconst keyDownHandlers = {\r\n  Enter(event, downshift) {\r\n    if (downshift.isOpen) {\r\n      // do something\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nWhat do you think?","created_at":"2018-02-26T21:28:41Z","updated_at":"2018-02-26T21:28:41Z","html_url":"https://github.com/paypal/downshift/pull/346#discussion_r170741664","pull_request_url":"https://api.github.com/repos/paypal/downshift/pulls/346","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/paypal/downshift/pulls/comments/170741664"},"html":{"href":"https://github.com/paypal/downshift/pull/346#discussion_r170741664"},"pull_request":{"href":"https://api.github.com/repos/paypal/downshift/pulls/346"}},"in_reply_to_id":170512681},"pull_request":{"url":"https://api.github.com/repos/paypal/downshift/pulls/346","id":171261914,"html_url":"https://github.com/paypal/downshift/pull/346","diff_url":"https://github.com/paypal/downshift/pull/346.diff","patch_url":"https://github.com/paypal/downshift/pull/346.patch","issue_url":"https://api.github.com/repos/paypal/downshift/issues/346","number":346,"state":"open","locked":false,"title":"Add keyDownHandlers prop","user":{"login":"hzhu","id":1811365,"avatar_url":"https://avatars2.githubusercontent.com/u/1811365?v=4","gravatar_id":"","url":"https://api.github.com/users/hzhu","html_url":"https://github.com/hzhu","followers_url":"https://api.github.com/users/hzhu/followers","following_url":"https://api.github.com/users/hzhu/following{/other_user}","gists_url":"https://api.github.com/users/hzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/hzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hzhu/subscriptions","organizations_url":"https://api.github.com/users/hzhu/orgs","repos_url":"https://api.github.com/users/hzhu/repos","events_url":"https://api.github.com/users/hzhu/events{/privacy}","received_events_url":"https://api.github.com/users/hzhu/received_events","type":"User","site_admin":false},"body":"<!-- What changes are being made? (What feature/bug is being fixed here?) -->\r\n\r\n**What**: Allow downshift to accept a new prop called `keyDownHandlers`. \r\n\r\n<!-- Why are these changes necessary? -->\r\n\r\n**Why**: This can be useful when one wants to customize key down handler behavior. It allows users to address issues such as #330 and #336 by passing an handler object to the `keyDownHandlers` prop. For example, in #330 when downshift is wrapped in a `<form>`, pressing `ENTER` key should call the `<form>'`s onSubmit handler. This doesn't happen because internally, downshift calls `event.preventDefault()` - preventing the `<form>` from submitting.\r\n\r\nBy [passing a custom handler](https://github.com/paypal/downshift/issues/330#issuecomment-367159522) for `ENTER` key, we can use a handler which does not call `event.preventDefault()`. \r\n\r\n<!-- How were these changes implemented? -->\r\n\r\n**How**: If `keyDownHandlers` is passed, the handlers in the object will be used when downshift handles a keyDown event. Specifically, the handler will be called in `input_handleKeyDown`.\r\n\r\n<!-- Have you done all of these things?  -->\r\n\r\n**Checklist**:\r\n\r\n<!-- add \"N/A\" to the end of each line that's irrelevant to your changes -->\r\n\r\n<!-- to check an item, place an \"x\" in the box like so: \"- [x] Documentation\" -->\r\n\r\n* [x] Documentation\r\n* [x] Tests\r\n* [ ] Ready to be merged\r\n* [ ] Added myself to contributors table\r\n\r\nP.S. Please let me know if something in this pull request isn't clear. I would love suggestions from the community as this is my first PR for Downshift! \r\n\r\nThank you for reviewing this PR. Thanks @kentcdodds, @austintackaberry, @indiesquidge, and @newyork-anthonyng for having a conversation on issue #330. Thanks to @kentcdodds for coming up with a flexible solution ❤️.\r\n\r\n","created_at":"2018-02-26T00:39:12Z","updated_at":"2018-02-26T21:28:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2b109eb886e014849b762dacafcae521dda634a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/paypal/downshift/pulls/346/commits","review_comments_url":"https://api.github.com/repos/paypal/downshift/pulls/346/comments","review_comment_url":"https://api.github.com/repos/paypal/downshift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/paypal/downshift/issues/346/comments","statuses_url":"https://api.github.com/repos/paypal/downshift/statuses/4a70590ee4213f26e0c92776e8346471e4baa39f","head":{"label":"hzhu:keyDownHandlers-prop","ref":"keyDownHandlers-prop","sha":"4a70590ee4213f26e0c92776e8346471e4baa39f","user":{"login":"hzhu","id":1811365,"avatar_url":"https://avatars2.githubusercontent.com/u/1811365?v=4","gravatar_id":"","url":"https://api.github.com/users/hzhu","html_url":"https://github.com/hzhu","followers_url":"https://api.github.com/users/hzhu/followers","following_url":"https://api.github.com/users/hzhu/following{/other_user}","gists_url":"https://api.github.com/users/hzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/hzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hzhu/subscriptions","organizations_url":"https://api.github.com/users/hzhu/orgs","repos_url":"https://api.github.com/users/hzhu/repos","events_url":"https://api.github.com/users/hzhu/events{/privacy}","received_events_url":"https://api.github.com/users/hzhu/received_events","type":"User","site_admin":false},"repo":{"id":122607444,"name":"downshift","full_name":"hzhu/downshift","owner":{"login":"hzhu","id":1811365,"avatar_url":"https://avatars2.githubusercontent.com/u/1811365?v=4","gravatar_id":"","url":"https://api.github.com/users/hzhu","html_url":"https://github.com/hzhu","followers_url":"https://api.github.com/users/hzhu/followers","following_url":"https://api.github.com/users/hzhu/following{/other_user}","gists_url":"https://api.github.com/users/hzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/hzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hzhu/subscriptions","organizations_url":"https://api.github.com/users/hzhu/orgs","repos_url":"https://api.github.com/users/hzhu/repos","events_url":"https://api.github.com/users/hzhu/events{/privacy}","received_events_url":"https://api.github.com/users/hzhu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hzhu/downshift","description":"🏎 Primitives to build simple, flexible, WAI-ARIA compliant enhanced input React components","fork":true,"url":"https://api.github.com/repos/hzhu/downshift","forks_url":"https://api.github.com/repos/hzhu/downshift/forks","keys_url":"https://api.github.com/repos/hzhu/downshift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hzhu/downshift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hzhu/downshift/teams","hooks_url":"https://api.github.com/repos/hzhu/downshift/hooks","issue_events_url":"https://api.github.com/repos/hzhu/downshift/issues/events{/number}","events_url":"https://api.github.com/repos/hzhu/downshift/events","assignees_url":"https://api.github.com/repos/hzhu/downshift/assignees{/user}","branches_url":"https://api.github.com/repos/hzhu/downshift/branches{/branch}","tags_url":"https://api.github.com/repos/hzhu/downshift/tags","blobs_url":"https://api.github.com/repos/hzhu/downshift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hzhu/downshift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hzhu/downshift/git/refs{/sha}","trees_url":"https://api.github.com/repos/hzhu/downshift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hzhu/downshift/statuses/{sha}","languages_url":"https://api.github.com/repos/hzhu/downshift/languages","stargazers_url":"https://api.github.com/repos/hzhu/downshift/stargazers","contributors_url":"https://api.github.com/repos/hzhu/downshift/contributors","subscribers_url":"https://api.github.com/repos/hzhu/downshift/subscribers","subscription_url":"https://api.github.com/repos/hzhu/downshift/subscription","commits_url":"https://api.github.com/repos/hzhu/downshift/commits{/sha}","git_commits_url":"https://api.github.com/repos/hzhu/downshift/git/commits{/sha}","comments_url":"https://api.github.com/repos/hzhu/downshift/comments{/number}","issue_comment_url":"https://api.github.com/repos/hzhu/downshift/issues/comments{/number}","contents_url":"https://api.github.com/repos/hzhu/downshift/contents/{+path}","compare_url":"https://api.github.com/repos/hzhu/downshift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hzhu/downshift/merges","archive_url":"https://api.github.com/repos/hzhu/downshift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hzhu/downshift/downloads","issues_url":"https://api.github.com/repos/hzhu/downshift/issues{/number}","pulls_url":"https://api.github.com/repos/hzhu/downshift/pulls{/number}","milestones_url":"https://api.github.com/repos/hzhu/downshift/milestones{/number}","notifications_url":"https://api.github.com/repos/hzhu/downshift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hzhu/downshift/labels{/name}","releases_url":"https://api.github.com/repos/hzhu/downshift/releases{/id}","deployments_url":"https://api.github.com/repos/hzhu/downshift/deployments","created_at":"2018-02-23T10:31:51Z","updated_at":"2018-02-23T10:31:53Z","pushed_at":"2018-02-26T20:17:36Z","git_url":"git://github.com/hzhu/downshift.git","ssh_url":"git@github.com:hzhu/downshift.git","clone_url":"https://github.com/hzhu/downshift.git","svn_url":"https://github.com/hzhu/downshift","homepage":"http://downshift.netlify.com/","size":601,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"paypal:master","ref":"master","sha":"5278c2c3c437e4861e7180d8a98160caff8872f7","user":{"login":"paypal","id":476675,"avatar_url":"https://avatars1.githubusercontent.com/u/476675?v=4","gravatar_id":"","url":"https://api.github.com/users/paypal","html_url":"https://github.com/paypal","followers_url":"https://api.github.com/users/paypal/followers","following_url":"https://api.github.com/users/paypal/following{/other_user}","gists_url":"https://api.github.com/users/paypal/gists{/gist_id}","starred_url":"https://api.github.com/users/paypal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paypal/subscriptions","organizations_url":"https://api.github.com/users/paypal/orgs","repos_url":"https://api.github.com/users/paypal/repos","events_url":"https://api.github.com/users/paypal/events{/privacy}","received_events_url":"https://api.github.com/users/paypal/received_events","type":"Organization","site_admin":false},"repo":{"id":98315735,"name":"downshift","full_name":"paypal/downshift","owner":{"login":"paypal","id":476675,"avatar_url":"https://avatars1.githubusercontent.com/u/476675?v=4","gravatar_id":"","url":"https://api.github.com/users/paypal","html_url":"https://github.com/paypal","followers_url":"https://api.github.com/users/paypal/followers","following_url":"https://api.github.com/users/paypal/following{/other_user}","gists_url":"https://api.github.com/users/paypal/gists{/gist_id}","starred_url":"https://api.github.com/users/paypal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paypal/subscriptions","organizations_url":"https://api.github.com/users/paypal/orgs","repos_url":"https://api.github.com/users/paypal/repos","events_url":"https://api.github.com/users/paypal/events{/privacy}","received_events_url":"https://api.github.com/users/paypal/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/paypal/downshift","description":"🏎 Primitives to build simple, flexible, WAI-ARIA compliant enhanced input React components","fork":false,"url":"https://api.github.com/repos/paypal/downshift","forks_url":"https://api.github.com/repos/paypal/downshift/forks","keys_url":"https://api.github.com/repos/paypal/downshift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paypal/downshift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paypal/downshift/teams","hooks_url":"https://api.github.com/repos/paypal/downshift/hooks","issue_events_url":"https://api.github.com/repos/paypal/downshift/issues/events{/number}","events_url":"https://api.github.com/repos/paypal/downshift/events","assignees_url":"https://api.github.com/repos/paypal/downshift/assignees{/user}","branches_url":"https://api.github.com/repos/paypal/downshift/branches{/branch}","tags_url":"https://api.github.com/repos/paypal/downshift/tags","blobs_url":"https://api.github.com/repos/paypal/downshift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paypal/downshift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paypal/downshift/git/refs{/sha}","trees_url":"https://api.github.com/repos/paypal/downshift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paypal/downshift/statuses/{sha}","languages_url":"https://api.github.com/repos/paypal/downshift/languages","stargazers_url":"https://api.github.com/repos/paypal/downshift/stargazers","contributors_url":"https://api.github.com/repos/paypal/downshift/contributors","subscribers_url":"https://api.github.com/repos/paypal/downshift/subscribers","subscription_url":"https://api.github.com/repos/paypal/downshift/subscription","commits_url":"https://api.github.com/repos/paypal/downshift/commits{/sha}","git_commits_url":"https://api.github.com/repos/paypal/downshift/git/commits{/sha}","comments_url":"https://api.github.com/repos/paypal/downshift/comments{/number}","issue_comment_url":"https://api.github.com/repos/paypal/downshift/issues/comments{/number}","contents_url":"https://api.github.com/repos/paypal/downshift/contents/{+path}","compare_url":"https://api.github.com/repos/paypal/downshift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paypal/downshift/merges","archive_url":"https://api.github.com/repos/paypal/downshift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paypal/downshift/downloads","issues_url":"https://api.github.com/repos/paypal/downshift/issues{/number}","pulls_url":"https://api.github.com/repos/paypal/downshift/pulls{/number}","milestones_url":"https://api.github.com/repos/paypal/downshift/milestones{/number}","notifications_url":"https://api.github.com/repos/paypal/downshift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paypal/downshift/labels{/name}","releases_url":"https://api.github.com/repos/paypal/downshift/releases{/id}","deployments_url":"https://api.github.com/repos/paypal/downshift/deployments","created_at":"2017-07-25T14:31:42Z","updated_at":"2018-02-26T18:19:55Z","pushed_at":"2018-02-26T20:17:37Z","git_url":"git://github.com/paypal/downshift.git","ssh_url":"git@github.com:paypal/downshift.git","clone_url":"https://github.com/paypal/downshift.git","svn_url":"https://github.com/paypal/downshift","homepage":"http://downshift.netlify.com/","size":588,"stargazers_count":3470,"watchers_count":3470,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":210,"mirror_url":null,"archived":false,"open_issues_count":20,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":210,"open_issues":20,"watchers":3470,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/paypal/downshift/pulls/346"},"html":{"href":"https://github.com/paypal/downshift/pull/346"},"issue":{"href":"https://api.github.com/repos/paypal/downshift/issues/346"},"comments":{"href":"https://api.github.com/repos/paypal/downshift/issues/346/comments"},"review_comments":{"href":"https://api.github.com/repos/paypal/downshift/pulls/346/comments"},"review_comment":{"href":"https://api.github.com/repos/paypal/downshift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/paypal/downshift/pulls/346/commits"},"statuses":{"href":"https://api.github.com/repos/paypal/downshift/statuses/4a70590ee4213f26e0c92776e8346471e4baa39f"}},"author_association":"NONE"}}
{"actor":{"display_login":"kentcdodds"}}