From 67ef5ca517b0dc12bed54622fe8edf6c10a196e4 Mon Sep 17 00:00:00 2001 From: Shreyag02 Date: Mon, 12 Oct 2026 01:13:36 +0530 Subject: [PATCH] fix: [select] pass searchValue to the autocomplete search input --- .../select/__tests__/select.test.tsx | 25 +++++++++++++++++++ .../react/components/select/select-root.tsx | 2 ++ 2 files changed, 27 insertions(+) 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 bde4165f2..5dd18f5d5 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) => {