mirror of
https://github.com/grafana/grafana.git
synced 2025-09-27 06:54:04 +08:00
MultiCombobox: Show placeholder
when there is no options selected (#99743)
This commit is contained in:
@ -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(<MultiCombobox options={options} value={['a']} onChange={jest.fn()} placeholder="Select" />);
|
||||
const input = screen.getByRole('combobox');
|
||||
expect(input).toHaveAttribute('placeholder', '');
|
||||
});
|
||||
|
||||
it.each([
|
||||
['a', 'b', 'c'],
|
||||
[1, 2, 3],
|
||||
|
@ -276,7 +276,7 @@ export const MultiCombobox = <T extends string | number>(props: MultiComboboxPro
|
||||
getDropdownProps({
|
||||
disabled,
|
||||
preventKeyAction: isOpen,
|
||||
placeholder,
|
||||
placeholder: visibleItems.length === 0 ? placeholder : '',
|
||||
ref: inputRef,
|
||||
style: { width: inputWidth },
|
||||
})
|
||||
|
Reference in New Issue
Block a user