Skip to content

Commit

Permalink
fix(Select): crash when mode=tag&&value={null}&&isPreview, close alib…
Browse files Browse the repository at this point in the history
  • Loading branch information
youluna committed Sep 17, 2020
1 parent e334c41 commit bcc4ddc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/select/base.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ export default class Base extends React.Component {
style={style}
className={className}
isPreview={isPreview}
value={fillProps ? valueDS[fillProps] : valueDS && valueDS.label}
value={valueDS ? (fillProps ? valueDS[fillProps] : valueDS.label) : ''}
/>
);
} else {
Expand All @@ -660,7 +660,7 @@ export default class Base extends React.Component {
style={style}
className={className}
isPreview={isPreview}
value={valueDS.map(i => i.label).join(', ')}
value={(valueDS || []).map(i => i.label).join(', ')}
/>
);
}
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 @@ -338,6 +338,19 @@ describe('Select', () => {
assert(wrapper.getDOMNode().innerText === '');
});

it('should renderPreview mode="tag"', () => {
const wrapper = mount(
<Select
isPreview
mode="tag"
dataSource={[]}
value={null}
/>
);

assert(wrapper.getDOMNode().innerText === '');
});

it('should support children null', () => {
wrapper.setProps({
children: [
Expand Down

0 comments on commit bcc4ddc

Please sign in to comment.