diff --git a/packages/grafana-ui/src/components/Segment/SegmentSelect.tsx b/packages/grafana-ui/src/components/Segment/SegmentSelect.tsx index 560fde7be52..e3efc8d15f1 100644 --- a/packages/grafana-ui/src/components/Segment/SegmentSelect.tsx +++ b/packages/grafana-ui/src/components/Segment/SegmentSelect.tsx @@ -1,9 +1,10 @@ import React, { HTMLProps, useRef } from 'react'; -import { css, cx } from '@emotion/css'; import useClickAway from 'react-use/lib/useClickAway'; import { SelectableValue } from '@grafana/data'; -import { Select } from '../Forms/Legacy/Select/Select'; +import { Select } from '../Select/Select'; +import { useTheme2 } from '../../themes/ThemeContext'; +/** @internal */ export interface Props extends Omit, 'value' | 'onChange'> { value?: SelectableValue; options: Array>; @@ -14,17 +15,19 @@ export interface Props extends Omit, 'value' | 'onC allowCustomValue?: boolean; } +/** @internal */ export function SegmentSelect({ value, options = [], onChange, onClickOutside, - width, + width: widthPixels, noOptionsMessage = '', allowCustomValue = false, ...rest }: React.PropsWithChildren>) { const ref = useRef(null); + const theme = useTheme2(); useClickAway(ref, () => { if (ref && ref.current) { @@ -39,15 +42,13 @@ export function SegmentSelect({ } }); + let width = widthPixels > 0 ? widthPixels / theme.spacing.gridSize : undefined; + return (