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> = ({
215
215
216
216
useEffect ( ( ) => {
217
217
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
+ }
221
233
} else {
222
234
setFirstDate ( dayjs ( startFrom ) ) ;
223
235
setSecondDate ( nextMonth ( dayjs ( startFrom ) ) ) ;
224
236
}
225
237
}
226
- } , [ startFrom , value ] ) ;
238
+ } , [ asSingle , startFrom , value ] ) ;
227
239
228
240
// Variables
229
241
const safePrimaryColor = useMemo ( ( ) => {
You can’t perform that action at this time.
0 commit comments