@@ -440,7 +440,6 @@ const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>((props, ref) => {
440440
441441 const savedOnOpen = useSavedCallback ( onOpen ) ;
442442
443- const effectiveWarn = warn && ! invalid ;
444443 const wrapperRef = useRef < HTMLDivElement > ( null ) ;
445444
446445 const datePickerClasses = cx ( `${ prefix } --date-picker` , {
@@ -460,38 +459,43 @@ const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>((props, ref) => {
460459 const childrenWithProps = React . Children . toArray ( children as any ) . map (
461460 // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
462461 ( child : any , index ) => {
462+ const childInvalid = child . props ?. invalid ;
463+ const childWarn = child . props ?. warn ;
464+ const mergedInvalid = invalid ?? childInvalid ;
465+ const mergedWarn = mergedInvalid ? false : ( warn ?? childWarn ) ;
466+
463467 if ( index === 0 && isComponentElement ( child , DatePickerInput ) ) {
464468 return React . cloneElement ( child , {
465469 datePickerType,
466470 ref : startInputField ,
467471 readOnly,
468- invalid,
469- warn : effectiveWarn ,
472+ invalid : mergedInvalid ,
473+ warn : mergedWarn ,
470474 } ) ;
471475 }
472476 if ( index === 1 && isComponentElement ( child , DatePickerInput ) ) {
473477 return React . cloneElement ( child , {
474478 datePickerType,
475479 ref : endInputField ,
476480 readOnly,
477- invalid,
478- warn : effectiveWarn ,
481+ invalid : mergedInvalid ,
482+ warn : mergedWarn ,
479483 } ) ;
480484 }
481485 if ( index === 0 ) {
482486 return React . cloneElement ( child , {
483487 ref : startInputField ,
484488 readOnly,
485- invalid,
486- warn : effectiveWarn ,
489+ invalid : mergedInvalid ,
490+ warn : mergedWarn ,
487491 } ) ;
488492 }
489493 if ( index === 1 ) {
490494 return React . cloneElement ( child , {
491495 ref : endInputField ,
492496 readOnly,
493- invalid,
494- warn : effectiveWarn ,
497+ invalid : mergedInvalid ,
498+ warn : mergedWarn ,
495499 } ) ;
496500 }
497501 }
0 commit comments