Skip to content

Commit

Permalink
fix: shortcus with range (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxiong10 committed Dec 17, 2019
1 parent b33c9b8 commit bb0255f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions __test__/date-picker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,19 @@ describe('DatePicker', () => {
btn.trigger('click');
const emitted = wrapper.emitted();
expect(emitted.input).toEqual([['2019/05/10']]);
wrapper.setProps({
range: true,
shortcuts: [
{
text: 'range',
onClick() {
return [date, date];
},
},
],
});
btn.trigger('click');
expect(emitted.input[1]).toEqual([['2019/05/10', '2019/05/10']]);
});

it('prop: popupClass', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/date-picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export default {
handleSelectShortcut(item) {
if (isObject(item) && typeof item.onClick === 'function') {
const date = item.onClick(this);
if (date instanceof Date) {
if (date) {
this.emitValue(date);
}
}
Expand Down

0 comments on commit bb0255f

Please sign in to comment.