diff --git a/packages/grafana-ui/src/components/Combobox/Combobox.tsx b/packages/grafana-ui/src/components/Combobox/Combobox.tsx index 54d0d552b53..6813b634318 100644 --- a/packages/grafana-ui/src/components/Combobox/Combobox.tsx +++ b/packages/grafana-ui/src/components/Combobox/Combobox.tsx @@ -156,6 +156,7 @@ export const Combobox = ({ onChange(selectedItem); }, defaultHighlightedIndex: selectedItemIndex ?? 0, + scrollIntoView: () => {}, onInputValueChange: ({ inputValue }) => { const customValueOption = @@ -223,8 +224,19 @@ export const Combobox = ({ setInputValue(selectedItem?.label ?? value?.toString() ?? ''); }, [selectedItem, setInputValue, value]); + const handleSuffixClick = useCallback(() => { + isOpen ? closeMenu() : openMenu(); + }, [isOpen, openMenu, closeMenu]); + const InputComponent = width === 'auto' ? AutoSizeInput : Input; + const suffixIcon = asyncLoading + ? 'spinner' + : // If it's loading, show loading icon. Otherwise, icon indicating menu state + isOpen + ? 'search' + : 'angle-down'; + return (
({ }} /> )} - { - if (isOpen) { - closeMenu(); - } else { - openMenu(); - } - }} - /> + + {/* When you click the input, it should just focus the text box. However, clicks on input suffix arent + translated to the input, so it blocks the input from being focused. So we need an additional event + handler here to open/close the menu. It should not have button role because we intentionally don't + want it in the a11y tree. */} + } - loading={asyncLoading} {...restProps} {...getInputProps({ ref: inputRef,