diff --git a/.betterer.results b/.betterer.results index 9a2bd1a8c8d..83032798feb 100644 --- a/.betterer.results +++ b/.betterer.results @@ -4107,12 +4107,6 @@ exports[`better eslint`] = { "public/app/features/search/utils.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/serviceaccounts/components/CreateTokenModal.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"], - [0, 0, 0, "Styles should be written using objects.", "3"] - ], "public/app/features/serviceaccounts/components/ServiceAccountProfile.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"] ], diff --git a/packages/grafana-ui/src/components/DateTimePickers/DatePicker/DatePicker.tsx b/packages/grafana-ui/src/components/DateTimePickers/DatePicker/DatePicker.tsx index c2a7d8f6457..358d985a169 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/DatePicker/DatePicker.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/DatePicker/DatePicker.tsx @@ -67,7 +67,6 @@ export const getStyles = (theme: GrafanaTheme2) => { return { modal: css({ zIndex: theme.zIndex.modal, - position: 'absolute', boxShadow: theme.shadows.z3, backgroundColor: theme.colors.background.primary, border: `1px solid ${theme.colors.border.weak}`, diff --git a/packages/grafana-ui/src/components/DateTimePickers/DatePickerWithInput/DatePickerWithInput.tsx b/packages/grafana-ui/src/components/DateTimePickers/DatePickerWithInput/DatePickerWithInput.tsx index 581d6b72e96..69933e8d645 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/DatePickerWithInput/DatePickerWithInput.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/DatePickerWithInput/DatePickerWithInput.tsx @@ -1,5 +1,6 @@ import { css } from '@emotion/css'; -import React, { ChangeEvent } from 'react'; +import { autoUpdate, flip, shift, useClick, useDismiss, useFloating, useInteractions } from '@floating-ui/react'; +import React, { ChangeEvent, useState } from 'react'; import { dateTime } from '@grafana/data'; @@ -35,17 +36,41 @@ export const DatePickerWithInput = ({ placeholder = 'Date', ...rest }: DatePickerWithInputProps) => { - const [open, setOpen] = React.useState(false); + const [open, setOpen] = useState(false); const styles = useStyles2(getStyles); + // the order of middleware is important! + // see https://floating-ui.com/docs/arrow#order + const middleware = [ + flip({ + // see https://floating-ui.com/docs/flip#combining-with-shift + crossAxis: false, + boundary: document.body, + }), + shift(), + ]; + + const { context, refs, floatingStyles } = useFloating({ + open, + placement: 'bottom-start', + onOpenChange: setOpen, + middleware, + whileElementsMounted: autoUpdate, + strategy: 'fixed', + }); + + const click = useClick(context); + const dismiss = useDismiss(context); + const { getReferenceProps, getFloatingProps } = useInteractions([dismiss, click]); + return (