mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 13:09:40 +08:00
fix: DatePicker date order (#17694)
* Fix selected time order #17346 * add test case
This commit is contained in:
parent
271b08192e
commit
ebe9097689
@ -150,6 +150,9 @@ class RangePicker extends React.Component<any, RangePickerState> {
|
||||
showDate: getShowDateFromValue(value) || showDate,
|
||||
}));
|
||||
}
|
||||
if (value[0] && value[0].diff(value[1]) > 0) {
|
||||
value[1] = undefined;
|
||||
}
|
||||
const [start, end] = value;
|
||||
props.onChange(value, [formatDate(start, props.format), formatDate(end, props.format)]);
|
||||
};
|
||||
|
@ -387,4 +387,17 @@ describe('RangePicker', () => {
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/17135
|
||||
it('the end time should be less than the start time', () => {
|
||||
const wrapper = mount(
|
||||
<RangePicker defaultValue={[moment(), moment()]} />,
|
||||
);
|
||||
wrapper.find('.ant-calendar-picker-input').simulate('click');
|
||||
const firstInput = wrapper.find('.ant-calendar-input').first();
|
||||
const secondInput = wrapper.find('.ant-calendar-input').last();
|
||||
firstInput.simulate('change', { target: { value: moment().add(1, 'day').format('YYYY-MM-DD')}});
|
||||
expect(firstInput.getDOMNode().value).toBe(moment().add(1, 'day').format('YYYY-MM-DD'));
|
||||
expect(secondInput.getDOMNode().value).toBe('');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user