Skip to content

Commit

Permalink
fix(DatePicker): issues range-picker clear when value only has start …
Browse files Browse the repository at this point in the history
…or end , close #3448
  • Loading branch information
lancely authored and eternalsky committed Mar 19, 2024
1 parent 6fcffd8 commit 67cf979
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions components/date-picker/__tests__/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,14 @@ describe('RangePicker', () => {
assert(!ret[0]);
assert(!ret[1]);
});
// issue: https://github.com/alibaba-fusion/next/issues/3448
it('should clear range when only half value', () => {
let ret;
wrapper = mount(<RangePicker defaultValue={[, endValue]} onChange={val => (ret = val)} />);
wrapper.find('i.next-input-clear-icon').simulate('click');
assert(!ret[0]);
assert(!ret[1]);
});

it('should input range value', function() {
this.timeout(3000);
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/range-picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ class RangePicker extends Component {
[PANEL.TIME]: timePanel,
}[state.panel];

const allowClear = state.startValue && state.endValue && hasClear;
const allowClear = (state.startValue || state.endValue) && hasClear;
let [startPlaceholder, endPlaceholder] = placeholder || [];

if (typeof placeholder === 'string') {
Expand Down

0 comments on commit 67cf979

Please sign in to comment.