This repository was archived by the owner on May 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff 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 } ;
Original file line number Diff line number Diff 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
2626beforeEach ( ( ) => {
@@ -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 ) ,
You can’t perform that action at this time.
0 commit comments