MultiCombobox: Show placeholder when there is no options selected (#99743)

This commit is contained in:
Laura Fernández
2025-01-29 15:02:53 +01:00
committed by GitHub
parent baaff6296f
commit 03f89a1925
2 changed files with 12 additions and 1 deletions

View File

@ -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],

View File

@ -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 },
})