Skip to content

Commit c2d4a81

Browse files
committed
fix: support on blur and make mode param optional for single props
1 parent b32f54d commit c2d4a81

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/components/experimental/DatePicker/DatePicker.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ type CommonProps = Pick<FieldProps, 'description' | 'errorMessage'> & {
4747
id?: string;
4848
name?: string;
4949
/** focus input on mount */
50-
autoFocus: boolean;
50+
autoFocus?: boolean;
51+
onBlur?: React.FocusEventHandler;
5152
};
5253

5354
type SingleProps = CommonProps & {
54-
mode: 'single';
55+
mode?: 'single';
5556
value: Date | null;
5657
onChange: (date: Date | null) => void;
5758
};
@@ -118,7 +119,8 @@ function DatePickerImpl(props: DatePickerProps): JSX.Element {
118119
maxValue,
119120
isDisabled,
120121
isInvalid,
121-
autoFocus
122+
autoFocus,
123+
onBlur
122124
} = props;
123125

124126
// legacy compat
@@ -344,6 +346,7 @@ function DatePickerImpl(props: DatePickerProps): JSX.Element {
344346
handleSelectSingle(next);
345347
}}
346348
autoFocus={autoFocus}
349+
onBlur={onBlur}
347350
actionIcon={
348351
<Button
349352
ref={triggerRef}
@@ -391,6 +394,7 @@ function DatePickerImpl(props: DatePickerProps): JSX.Element {
391394
readOnly,
392395
autoFocus,
393396
onBlur: event => {
397+
onBlur?.(event);
394398
const nextEl = event.relatedTarget as HTMLElement | null;
395399
if (nextEl && nextEl === triggerRef.current) return;
396400
if (modeLocal === 'single') commitSingle(event.currentTarget.value);

0 commit comments

Comments
 (0)