File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -215,15 +215,27 @@ const Datepicker: React.FC<DatepickerType> = ({
215215
216216 useEffect ( ( ) => {
217217 if ( startFrom && dayjs ( startFrom ) . isValid ( ) ) {
218- if ( value ?. startDate != null ) {
219- setFirstDate ( dayjs ( value . startDate ) ) ;
220- setSecondDate ( nextMonth ( dayjs ( value . startDate ) ) ) ;
218+ const startDate = value ?. startDate ;
219+ const endDate = value ?. endDate ;
220+ if ( startDate && dayjs ( startDate ) . isValid ( ) ) {
221+ setFirstDate ( dayjs ( startDate ) ) ;
222+ if ( ! asSingle ) {
223+ if (
224+ endDate &&
225+ dayjs ( endDate ) . isValid ( ) &&
226+ dayjs ( endDate ) . startOf ( "month" ) . isAfter ( dayjs ( startDate ) )
227+ ) {
228+ setSecondDate ( dayjs ( endDate ) ) ;
229+ } else {
230+ setSecondDate ( nextMonth ( dayjs ( startDate ) ) ) ;
231+ }
232+ }
221233 } else {
222234 setFirstDate ( dayjs ( startFrom ) ) ;
223235 setSecondDate ( nextMonth ( dayjs ( startFrom ) ) ) ;
224236 }
225237 }
226- } , [ startFrom , value ] ) ;
238+ } , [ asSingle , startFrom , value ] ) ;
227239
228240 // Variables
229241 const safePrimaryColor = useMemo ( ( ) => {
You can’t perform that action at this time.
0 commit comments