Skip to content

Commit

Permalink
fix(DatePicker2): default current day when next range is empty, close #…
Browse files Browse the repository at this point in the history
…3877 (#4711)

* fix(DatePicker2): [DatePicker2] remove default range 24hr,close #3877

* fix(DatePicker2): [DatePicker2] update test,close #3877

---------

Co-authored-by: lancely <[email protected]>
  • Loading branch information
seven-lh and lancely authored Jan 10, 2024
1 parent 2f71df9 commit 62eec1b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions components/date-picker2/__tests__/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,26 @@ describe('Picker', () => {
wrapper.unmount();
wrapper = null;
}
});
// fix: https://github.com/alibaba-fusion/next/issues/3877
it('should not select default endDate',()=>{
const currentDate = dayjs();
const currentDateStr = currentDate.format('YYYY-MM-DD');
const disabledDate = function (date, mode) {
return currentDate.date() !== date.date();
};
wrapper = mount(<RangePicker visible showTime disabledDate={disabledDate} />);
clickDate(currentDateStr);
clickTime('12');
clickTime('12', 'minute');
clickTime('12', 'second');
assert.deepEqual(getStrValue(), [`${currentDateStr} 12:12:12`, '']);
clickOk();
clickTime('16');
clickTime('16', 'minute');
clickTime('35', 'second');
clickOk();
assert.deepEqual(getStrValue(), [`${currentDateStr} 12:12:12`, `${currentDateStr} 16:16:35`]);
});
// https://github.com/alibaba-fusion/next/issues/2641
it('value controlled issue', () => {
Expand Down
4 changes: 2 additions & 2 deletions components/date-picker2/panels/range-panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ class RangePanel extends React.Component {
if (!curDateVal) {
curDateVal =
inputType === BEGIN && end
? end.subtract(1, 'day')
? end
: inputType === END && begin
? begin.add(1, 'day')
? begin
: datejs();
}
curDateVal = setTime(curDateVal, v);
Expand Down

0 comments on commit 62eec1b

Please sign in to comment.