From 290aa153e014d414925ce22c73a779efaf97abec Mon Sep 17 00:00:00 2001 From: Ivan Leonenko Date: Fri, 23 Sep 2016 11:00:05 +0200 Subject: [PATCH 1/2] Fix for Creatable doesn't allow input key down handling. Issue #1247 --- src/Creatable.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Creatable.js b/src/Creatable.js index 6732d98398..1325d78513 100644 --- a/src/Creatable.js +++ b/src/Creatable.js @@ -157,7 +157,7 @@ const Creatable = React.createClass({ }, onInputKeyDown (event) { - const { shouldKeyDownEventCreateNewOption } = this.props; + const { shouldKeyDownEventCreateNewOption, onInputKeyDown } = this.props; const focusedOption = this.select.getFocusedOption(); if ( @@ -169,6 +169,8 @@ const Creatable = React.createClass({ // Prevent decorated Select from doing anything additional with this keyDown event event.preventDefault(); + } else if (onInputKeyDown) { + onInputKeyDown(event); } }, From d2ff4a91898a8208afa526e26d21362dcfbe4fff Mon Sep 17 00:00:00 2001 From: Ivan Leonenko Date: Fri, 23 Sep 2016 11:36:49 +0200 Subject: [PATCH 2/2] Add unit test for fix - Creatable doesn't allow input key down handling. #1247 --- test/Creatable-test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Creatable-test.js b/test/Creatable-test.js index de6bfa42ff..968478fd9a 100644 --- a/test/Creatable-test.js +++ b/test/Creatable-test.js @@ -232,4 +232,9 @@ describe('Creatable', () => { expect(test(188), 'to be', true); expect(test(1), 'to be', false); }); + + it('default :onInputKeyDown should run user provided handler.', (done) => { + createControl({ onInputKeyDown: event => done() }); + return creatableInstance.onInputKeyDown({ keyCode: 97 }); + }); });