fix(date-picker): showTime should work correctly when format is function (#27156)

This commit is contained in:
Kermit Xuan 2020-10-14 23:00:18 +08:00 committed by GitHub
parent 43e2651b9c
commit e883e4ba40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -138,6 +138,13 @@ describe('DatePicker', () => {
.length,
).toBe(60);
});
it('showTime should work correctly when format is custom function', () => {
const wrapper = mount(
<DatePicker defaultValue={moment()} showTime format={val => val.format('YYYY-MM-DD')} open />,
);
const input = wrapper.find('input').simulate('mousedown');
expect(input.simulate.bind(input, 'focus')).not.toThrowError();
});
it('12 hours', () => {
const wrapper = mount(

View File

@ -56,6 +56,11 @@ export function getTimeProps<DateType>(
return showTimeObj;
}
if (typeof firstFormat === 'function') {
// format of showTime should use default when format is custom format function
delete showTimeObj.format;
}
return {
showTime: showTimeObj,
};