Skip to content

Commit b79267c

Browse files
#219 Close dateinput's datepicker on tab key press
1 parent 1d104e2 commit b79267c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

libs/date/src/DateInput.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ export default function DateInput({
267267
setOpened(false);
268268
};
269269

270+
const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
271+
if (e.key === "Tab") {
272+
setOpened(false);
273+
}
274+
};
275+
270276
return (
271277
<div className={className}>
272278
<DateInputInput
@@ -281,6 +287,7 @@ export default function DateInput({
281287
mask={getMaskFromFormat(typedValue, finalDateFormat)}
282288
dateFormat={dateFormat}
283289
tokens={{ textColor: !value ? "text-body-light" : undefined }}
290+
onKeyDown={onKeyDown}
284291
/>
285292
<Popover
286293
className="z-50"

0 commit comments

Comments
 (0)