diff --git a/packages/grafana-ui/src/components/Combobox/MultiCombobox.test.tsx b/packages/grafana-ui/src/components/Combobox/MultiCombobox.test.tsx index 66444644ca461..8ed509b26dbff 100644 --- a/packages/grafana-ui/src/components/Combobox/MultiCombobox.test.tsx +++ b/packages/grafana-ui/src/components/Combobox/MultiCombobox.test.tsx @@ -61,6 +61,17 @@ describe('MultiCombobox', () => { expect(screen.getByPlaceholderText('Select')).toBeInTheDocument(); }); + it('should not render with placeholder when options selected', async () => { + const options = [ + { label: 'A', value: 'a' }, + { label: 'B', value: 'b' }, + { label: 'C', value: 'c' }, + ]; + render(); + const input = screen.getByRole('combobox'); + expect(input).toHaveAttribute('placeholder', ''); + }); + it.each([ ['a', 'b', 'c'], [1, 2, 3], diff --git a/packages/grafana-ui/src/components/Combobox/MultiCombobox.tsx b/packages/grafana-ui/src/components/Combobox/MultiCombobox.tsx index 104f638de6043..1d5ab5bd6d8da 100644 --- a/packages/grafana-ui/src/components/Combobox/MultiCombobox.tsx +++ b/packages/grafana-ui/src/components/Combobox/MultiCombobox.tsx @@ -276,7 +276,7 @@ export const MultiCombobox = (props: MultiComboboxPro getDropdownProps({ disabled, preventKeyAction: isOpen, - placeholder, + placeholder: visibleItems.length === 0 ? placeholder : '', ref: inputRef, style: { width: inputWidth }, })