TimePicker: Clicking outside the TimePicker/TimePickerCalendar now pr… (#40956)

* TimePicker: Clicking outside the TimePicker/TimePickerCalendar now properly dismisses the popup

* Slightly tidier syntax

* Don't forget to lint...
This commit is contained in:
Ashley Harrison 2021-10-29 10:31:56 +01:00 committed by GitHub
parent afdd9b2455
commit 283c19a129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -85,7 +85,7 @@ export function UnthemedTimeRangePicker(props: TimeRangePickerProps): ReactEleme
};
const ref = createRef<HTMLElement>();
const { overlayProps } = useOverlay({ onClose, isOpen }, ref);
const { overlayProps } = useOverlay({ onClose, isDismissable: true, isOpen }, ref);
const styles = getStyles(theme);
const hasAbsolute = isDateTime(value.raw.from) || isDateTime(value.raw.to);

View File

@ -76,9 +76,16 @@ const stopPropagation = (event: React.MouseEvent<HTMLDivElement>) => event.stopP
function TimePickerCalendar(props: TimePickerCalendarProps) {
const theme = useTheme2();
const styles = getStyles(theme, props.isReversed);
const { isOpen, isFullscreen } = props;
const { isOpen, isFullscreen, onClose } = props;
const ref = React.createRef<HTMLElement>();
const { overlayProps } = useOverlay(props, ref);
const { overlayProps } = useOverlay(
{
isDismissable: true,
isOpen,
onClose,
},
ref
);
if (!isOpen) {
return null;