diff --git a/packages/react/components/select/__tests__/select.test.tsx b/packages/react/components/select/__tests__/select.test.tsx index 0a48a178f..8349a4200 100644 --- a/packages/react/components/select/__tests__/select.test.tsx +++ b/packages/react/components/select/__tests__/select.test.tsx @@ -329,5 +329,30 @@ describe('Select', () => { expect(options[0]).toHaveTextContent('Apple'); expect(options[1]).toHaveTextContent('Pineapple'); }); + + it('shows a controlled searchValue in the search input', async () => { + render(); + + fireEvent.click(screen.getByLabelText('Select option')); + await flushMicrotasks(); + const searchInput = screen.getByPlaceholderText('Search...'); + fireEvent.change(searchInput, { target: { value: 'b' } }); + await flushMicrotasks(); + + expect(searchInput).toHaveValue('app'); + }); + + it('shows and filters by defaultSearchValue', async () => { + render(); + + fireEvent.click(screen.getByLabelText('Select option')); + await flushMicrotasks(); + + expect(screen.getByPlaceholderText('Search...')).toHaveValue('app'); + const options = screen.getAllByRole('option'); + expect(options.length).toBe(2); + expect(options[0]).toHaveTextContent('Apple'); + expect(options[1]).toHaveTextContent('Pineapple'); + }); }); }); diff --git a/packages/react/components/select/select-root.tsx b/packages/react/components/select/select-root.tsx index 3e3819ddb..5a0321ecf 100644 --- a/packages/react/components/select/select-root.tsx +++ b/packages/react/components/select/select-root.tsx @@ -219,6 +219,8 @@ export const SelectRoot = (props: SelectRootProps) => {