Skip to content

Commit

Permalink
fix: panel doesn't close after picking time (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxiong10 committed Nov 22, 2019
1 parent bf949af commit 8657d49
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions __test__/date-picker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,22 @@ describe('DatePicker', () => {
const emitted = wrapper.emitted();
expect(emitted.input[0][0]).toEqual([null, null]);
});

it('feat: should close popup when click time in datetime mode', () => {
wrapper = mount(DatePicker, {
propsData: {
type: 'datetime',
timePickerOptions: {
start: '00:00',
step: '00:30',
end: '23:30',
},
open: true,
showTimePanel: true,
},
});
const el = wrapper.find('.mx-time-option');
el.trigger('click');
expect(wrapper.emitted().close).toBeTruthy();
});
});
3 changes: 2 additions & 1 deletion src/date-picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ export default {
return value;
},
afterEmitValue(type) {
if (!type || type === this.type) {
// this.type === 'datetime', click the time should close popup
if (!type || type === this.type || type === 'time') {
this.closePopup();
}
},
Expand Down

0 comments on commit 8657d49

Please sign in to comment.