From 22dbc23f6e0cda8a8311d7d95999baaac6cc4f0b Mon Sep 17 00:00:00 2001 From: Keita Moromizato Date: Thu, 22 Jun 2017 13:49:51 +0900 Subject: [PATCH 1/2] fix: Ignore Enter key press event of combined character --- src/Autosuggest.js | 3 +++ test/always-render-suggestions/AutosuggestApp.test.js | 6 ++++++ test/helpers.js | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/src/Autosuggest.js b/src/Autosuggest.js index 438e74c1..d6446b4c 100644 --- a/src/Autosuggest.js +++ b/src/Autosuggest.js @@ -561,6 +561,9 @@ export default class Autosuggest extends Component { break; case 'Enter': { + // Ignore enter of combined character + if (event.keyCode === 229) break; + const highlightedSuggestion = this.getHighlightedSuggestion(); if (isOpen && !alwaysRenderSuggestions) { diff --git a/test/always-render-suggestions/AutosuggestApp.test.js b/test/always-render-suggestions/AutosuggestApp.test.js index ab78cdd4..587fae0b 100644 --- a/test/always-render-suggestions/AutosuggestApp.test.js +++ b/test/always-render-suggestions/AutosuggestApp.test.js @@ -11,6 +11,7 @@ import { blurInput, clickEscape, clickEnter, + clickCombinedCharacterEnter, clickDown, clickUp, focusAndSetInputValue @@ -106,6 +107,11 @@ describe('Autosuggest with alwaysRenderSuggestions={true}', () => { clickEnter(); expectSuggestions(['Perl', 'PHP', 'Python']); }); + + it('should not hide suggestions if enter event for combined character', () => { + clickCombinedCharacterEnter(); + expectSuggestions(['Perl', 'PHP', 'Python']); + }); }); describe('when pressing Escape', () => { diff --git a/test/helpers.js b/test/helpers.js index 0b2c482c..f196c570 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -216,6 +216,11 @@ export const clickEnter = () => { clock.tick(1); }; +export const clickCombinedCharacterEnter = () => { + Simulate.keyDown(input, { key: 'Enter', keyCode: 229 }); + clock.tick(1); +}; + export const clickDown = (count = 1) => { for (let i = 0; i < count; i++) { Simulate.keyDown(input, { key: 'ArrowDown' }); From 8bf6d8102c98c14d5d6ff7e4ded9b023447b2771 Mon Sep 17 00:00:00 2001 From: Keita Moromizato Date: Thu, 22 Jun 2017 13:56:10 +0900 Subject: [PATCH 2/2] run build