diff --git a/packages/grafana-ui/src/components/Segment/SegmentInput.tsx b/packages/grafana-ui/src/components/Segment/SegmentInput.tsx index ebc026ff0e1..b046f842c57 100644 --- a/packages/grafana-ui/src/components/Segment/SegmentInput.tsx +++ b/packages/grafana-ui/src/components/Segment/SegmentInput.tsx @@ -12,18 +12,21 @@ export interface SegmentInputProps extends SegmentProps { const FONT_SIZE = 14; export function SegmentInput({ - value, + value: initialValue, onChange, Component, className, }: React.PropsWithChildren>) { const ref = useRef(null); - const [inputWidth, setInputWidth] = useState(measureText(value.toString(), FONT_SIZE).width); + const [value, setValue] = useState(initialValue); + const [inputWidth, setInputWidth] = useState(measureText(initialValue.toString(), FONT_SIZE).width); const [Label, , expanded, setExpanded] = useExpandableLabel(false); useClickAway(ref, () => setExpanded(false)); if (!expanded) { - return