diff --git a/packages/grafana-ui/src/components/Combobox/useComboboxFloat.ts b/packages/grafana-ui/src/components/Combobox/useComboboxFloat.ts index 83eb2631a62..f5803afdf2e 100644 --- a/packages/grafana-ui/src/components/Combobox/useComboboxFloat.ts +++ b/packages/grafana-ui/src/components/Combobox/useComboboxFloat.ts @@ -22,7 +22,10 @@ export const useComboboxFloat = (items: Array>, const inputRef = useRef(null); const floatingRef = useRef(null); const scrollRef = useRef(null); - const [popoverMaxSize, setPopoverMaxSize] = useState<{ width: number; height: number } | undefined>(undefined); + const [popoverMaxSize, setPopoverMaxSize] = useState<{ width: number; height: number }>({ + width: 0, + height: 0, + }); // set initial values to prevent infinite size, briefly removing the list virtualization const scrollbarWidth = useMemo(() => getScrollbarWidth(), []); @@ -72,10 +75,10 @@ export const useComboboxFloat = (items: Array>, const floatStyles = { ...floatingStyles, width: longestItemWidth, - maxWidth: popoverMaxSize?.width, + maxWidth: popoverMaxSize.width, minWidth: inputRef.current?.offsetWidth, - maxHeight: popoverMaxSize?.height, + maxHeight: popoverMaxSize.height, }; return { inputRef, floatingRef, scrollRef, floatStyles };