close picker on pressing enter on time fields

This commit is contained in:
Ankur Singhal 2022-03-30 18:46:48 +05:30
parent 45bc4b71f2
commit 75a3e9262a

View File

@ -182,6 +182,13 @@ function DatePickerComponent(props: DatePickerComponentProps) {
setDatePickerVisibility(nextOpenState);
}
function handleTimePickerKeydown(e: React.KeyboardEvent) {
if (e.key === "Enter") {
setDatePickerVisibility(false);
e.stopPropagation();
}
}
return (
<StyledDateInput
className={Classes.DATE_PICKER_OVARLAY}
@ -205,6 +212,9 @@ function DatePickerComponent(props: DatePickerComponentProps) {
isOpen: isDatePickerVisible,
}}
showActionsBar={props.showActionsBar}
timePickerProps={{
onKeyDown: handleTimePickerKeydown,
}}
timePrecision={props.timePrecision}
value={props.value}
/>