diff --git a/packages/ui/src/fields/Select/index.tsx b/packages/ui/src/fields/Select/index.tsx index 3e89cd11be..26d27b72d1 100644 --- a/packages/ui/src/fields/Select/index.tsx +++ b/packages/ui/src/fields/Select/index.tsx @@ -112,10 +112,10 @@ const SelectFieldComponent: SelectFieldClientComponent = (props) => { Error={Error} filterOption={ selectFilterOptions - ? ({ value }) => + ? ({ label, value }, search) => selectFilterOptions?.some( (option) => (typeof option === 'string' ? option : option.value) === value, - ) + ) && label.toLowerCase().includes(search.toLowerCase()) : undefined } hasMany={hasMany} diff --git a/test/fields/collections/Select/e2e.spec.ts b/test/fields/collections/Select/e2e.spec.ts index 71823aa1f4..a2f91395a5 100644 --- a/test/fields/collections/Select/e2e.spec.ts +++ b/test/fields/collections/Select/e2e.spec.ts @@ -110,4 +110,16 @@ describe('Select', () => { await field.click({ delay: 100 }) await expect(options.locator('text=One')).toBeHidden() }) + + test('should retain search when reducing options', async () => { + await page.goto(url.create) + const field = page.locator('#field-selectWithFilteredOptions') + await field.click({ delay: 100 }) + const options = page.locator('.rs__option') + await expect(options.locator('text=One')).toBeVisible() + await expect(options.locator('text=Two')).toBeVisible() + await field.locator('input').fill('On') + await expect(options.locator('text=One')).toBeVisible() + await expect(options.locator('text=Two')).toBeHidden() + }) })