Skip to content

Commit

Permalink
fix(Select): value no show fillProps with empty dataSource. Close #715
Browse files Browse the repository at this point in the history
  • Loading branch information
bindoon committed May 24, 2019
1 parent 7bd2d3f commit 70a15ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/select/select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,10 @@ class Select extends Base {
return null;
}

const retvalue = fillProps ? value[fillProps] : valueRender(value);
const retvalue =
fillProps && fillProps in value
? value[fillProps]
: valueRender(value);
// 0 => '0'
return typeof retvalue === 'number'
? retvalue.toString()
Expand Down
11 changes: 11 additions & 0 deletions test/select/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@ describe('Select', () => {
assert(wrapper.find('.next-select em').text() === 'yyy');
});

it('should support fillProps=anything with empty dataSource', () => {
wrapper.setProps({
value: 'jack',
visible: true,
fillProps: 'anything',
dataSource: []
});

assert(wrapper.find('.next-select em').text() === 'jack');
});

it('should support disabled', () => {
wrapper.setProps({
disabled: true,
Expand Down

0 comments on commit 70a15ab

Please sign in to comment.