diff --git a/packages/grafana-ui/src/components/DateTimePickers/TimeRangeInput.tsx b/packages/grafana-ui/src/components/DateTimePickers/TimeRangeInput.tsx index d07788bf97e..7ef005c42c6 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/TimeRangeInput.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/TimeRangeInput.tsx @@ -1,8 +1,7 @@ import { css, cx } from '@emotion/css'; -import { useDialog } from '@react-aria/dialog'; +import { useDismiss, useFloating, useInteractions } from '@floating-ui/react'; import { FocusScope } from '@react-aria/focus'; -import { useOverlay } from '@react-aria/overlays'; -import { createRef, FormEvent, MouseEvent, useState } from 'react'; +import { FormEvent, MouseEvent, useState } from 'react'; import { dateTime, getDefaultTimeRange, GrafanaTheme2, TimeRange, TimeZone } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; @@ -79,22 +78,21 @@ export const TimeRangeInput = ({ onChange({ from, to, raw: { from, to } }); }; - const overlayRef = createRef(); - const buttonRef = createRef(); + const { refs, floatingStyles, context } = useFloating({ + open: isOpen, + onOpenChange: setIsOpen, + placement: 'bottom-start', + strategy: 'fixed', + }); - const { dialogProps } = useDialog({}, overlayRef); - - const { overlayProps } = useOverlay( - { - onClose, - isDismissable: true, - isOpen, - shouldCloseOnInteractOutside: (element) => { - return !buttonRef.current?.contains(element); - }, + const dismiss = useDismiss(context, { + bubbles: { + outsidePress: false, }, - overlayRef - ); + }); + + const { getReferenceProps, getFloatingProps } = useInteractions([dismiss]); + return (
{isOpen && ( -
+
{ marginLeft: 0, position: 'absolute', top: '116%', - zIndex: theme.zIndex.dropdown, + zIndex: theme.zIndex.modal, }), pickerInput: cx( inputStyles.input,