Skip to content

Commit

Permalink
Merge pull request #514 from bindoon/fix-select-autocomplete
Browse files Browse the repository at this point in the history
fix(Select): AutoComplete can input space with popupContent. Close #500
  • Loading branch information
youluna authored Apr 1, 2019
2 parents 54b74b6 + 07dc088 commit 5d53417
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/select/auto-complete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class AutoComplete extends Base {
handleTriggerKeyDown(e) {
const { popupContent, onToggleHighlightItem, onKeyDown } = this.props;
if (popupContent) {
e.stopPropagation(); //stopPropagation can make use onChange triggerd while typing space('') in Input
return onKeyDown(e);
}

Expand All @@ -229,7 +230,7 @@ class AutoComplete extends Base {
this.chooseHighlightItem(e);
break;
case KEYCODE.SPACE:
// 防止 Popup 监听到 space key 触发 onVisibleChange
// stopPropagation can make use onChange triggerd while typing space('') in Input
e.stopPropagation();
break;
case KEYCODE.ESC:
Expand Down
13 changes: 13 additions & 0 deletions test/select/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,19 @@ describe('AutoComplete', () => {
// assert(wrapper.find('input').prop('value') === 'a');
});

// simulate keydown not work in test event
// it('should input keyCode space with popupContent', () => {
// wrapper.setProps({
// popupContent: <div>any</div>,
// visible: true,
// });

// wrapper.find('input').simulate('keydown', { keyCode: 32 });

// wrapper.update();
// assert(wrapper.find('input').prop('value') === ' ');
// });

// it('should fix onChange conflict under IE9&IE10', () => {
// let changed = false,
// onChange = () => { changed = true };
Expand Down

0 comments on commit 5d53417

Please sign in to comment.