Skip to content

Commit c9a1590

Browse files
authored
fix(ui): search in select fields with filterOptions (#13397)
Fixes #13236
1 parent e870be0 commit c9a1590

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/ui/src/fields/Select/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ const SelectFieldComponent: SelectFieldClientComponent = (props) => {
112112
Error={Error}
113113
filterOption={
114114
selectFilterOptions
115-
? ({ value }) =>
115+
? ({ label, value }, search) =>
116116
selectFilterOptions?.some(
117117
(option) => (typeof option === 'string' ? option : option.value) === value,
118-
)
118+
) && label.toLowerCase().includes(search.toLowerCase())
119119
: undefined
120120
}
121121
hasMany={hasMany}

test/fields/collections/Select/e2e.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,16 @@ describe('Select', () => {
110110
await field.click({ delay: 100 })
111111
await expect(options.locator('text=One')).toBeHidden()
112112
})
113+
114+
test('should retain search when reducing options', async () => {
115+
await page.goto(url.create)
116+
const field = page.locator('#field-selectWithFilteredOptions')
117+
await field.click({ delay: 100 })
118+
const options = page.locator('.rs__option')
119+
await expect(options.locator('text=One')).toBeVisible()
120+
await expect(options.locator('text=Two')).toBeVisible()
121+
await field.locator('input').fill('On')
122+
await expect(options.locator('text=One')).toBeVisible()
123+
await expect(options.locator('text=Two')).toBeHidden()
124+
})
113125
})

0 commit comments

Comments
 (0)