Skip to content

Commit

Permalink
fix(Select): fix Select with useVirtual when empty dataSource (#164)
Browse files Browse the repository at this point in the history
* fix(Select): fix Select with useVirtual when empty dataSource
  • Loading branch information
bojoyzhou authored and youluna committed Jan 9, 2019
1 parent b2f9f5f commit 54da63f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/select/base.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export default class Base extends React.Component {
};

return (
useVirtual ?
useVirtual && children.length ?
<div className={`${prefix}select-menu-wrapper`} style={{position: 'relative'}}>
<VirtualList
itemsRenderer={(items, ref) => {
Expand Down
23 changes: 23 additions & 0 deletions test/select/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,3 +748,26 @@ describe('AutoComplete', () => {
});
});
});

describe('virtual list', () => {
it('should works with showSearch', (done) => {
const dataSource = [{label: '海关总署', value: '0000'}, {label: '北京关区', value: '0100'}, {label: '机场单证', value: '0101'}, {label: '京监管处', value: '0102'}, {label: '京关展览', value: '0103'}, {label: '京一处', value: '0104'}, {label: '京二处', value: '0105'}, {label: '京关关税', value: '0106'}, {label: '机场库区', value: '0107'}, {label: '京通关处', value: '0108'}];

const wrapper = mount(<Select placeholder="选择尺寸" useVirtual showSearch style={{float: 'right'}} dataSource={dataSource} />);

wrapper.update();
wrapper.simulate('click');

const input = wrapper.find('input').instance();
input.value = 'fff';
wrapper.find('input').simulate('change');
wrapper.find('input').simulate('keydown', {
key: 'Enter',
keyCode: 13,
which: 13
});
setTimeout(() => {
done();
}, 200);
});
});

0 comments on commit 54da63f

Please sign in to comment.