Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 67aee9f

Browse files
committed
linter fixes, pr suggestion
1 parent a530f57 commit 67aee9f

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/components/DateRange/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ class DateRange extends Component {
4343
return addDays(value, dayOffset);
4444
}
4545
if (retainEndDateOnFirstSelection) {
46-
// allow the unset end date to stay as-is
47-
if (!endDate) {
46+
if (!endDate || isBefore(value, endDate)) {
4847
return endDate;
4948
}
50-
return !isBefore(value, endDate) ? value : endDate;
49+
return value;
5150
}
5251
return value || now;
5352
};

src/components/DateRange/index.test.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const compareRanges = (newRange, assertionRange) => {
2020
return expect(newRange[key]).toEqual(assertionRange[key]);
2121
}
2222
return expect(isSameDay(newRange[key], assertionRange[key])).toEqual(true);
23-
})
23+
});
2424
};
2525

2626
beforeEach(() => {
@@ -68,11 +68,13 @@ describe('DateRange', () => {
6868
});
6969

7070
test('calculate new selection by retaining the unset end date, based on retainEndDateOnFirstSelection prop', () => {
71-
testRenderer.update(<DateRange
72-
{...commonProps}
73-
ranges={[{ ...commonProps.ranges[0], endDate: null }]}
74-
retainEndDateOnFirstSelection
75-
/>);
71+
testRenderer.update(
72+
<DateRange
73+
{...commonProps}
74+
ranges={[{ ...commonProps.ranges[0], endDate: null }]}
75+
retainEndDateOnFirstSelection
76+
/>
77+
);
7678
const methodResult = instance.calcNewSelection(subDays(endDate, 10), true);
7779
compareRanges(methodResult.range, {
7880
startDate: subDays(endDate, 10),

0 commit comments

Comments
 (0)