mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Combobox: Fix list not being virtualized initially in some cases (#100188)
* Combobox: Set arbitrary initial max size * Remove ? * Set initial values to 0
This commit is contained in:
parent
1467d4b3e3
commit
677060862c
@ -22,7 +22,10 @@ export const useComboboxFloat = (items: Array<ComboboxOption<string | number>>,
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const floatingRef = useRef<HTMLDivElement>(null);
|
||||
const scrollRef = useRef<HTMLDivElement>(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<ComboboxOption<string | number>>,
|
||||
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 };
|
||||
|
Loading…
Reference in New Issue
Block a user