mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
fix(date-picker): showTime should work correctly when format is function (#27156)
This commit is contained in:
parent
43e2651b9c
commit
e883e4ba40
@ -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(
|
||||
|
@ -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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user