payloadcms / payloadcms/payload
'listSearchableFields' does not support searching by select field labels (only values)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug
When using listSearchableFields in a collection, search queries only match the stored value of a select field, not the label.
In cases where label and value differ, users cannot search using the label shown in the UI, which leads to a poor admin experience.
Link to the code that reproduces this issue
https://github.com/MeghaPurohit306/payload
Reproduction Steps
- Define a Field with an options array where label and values are different for options (or use the reproduction repo):
- `import type { CollectionConfig } from 'payload'
export const UserStatusCollection: CollectionConfig = {
slug: 'user-statuses',
admin: {
useAsTitle: 'status',
listSearchableFields: ['status'],
},
fields: [
{
name: 'status',
type: 'select',
label: 'User Status',
options: [
{ label: 'Active User', value: 'active' },
{ label: 'Expired User', value: 'expired' },
{ label: 'Failed User', value: 'failed' },
{ label: 'Cancelled User', value: 'cancelled' },
],
required: true,
},
],
}
`
- Open a document in the admin panel containing this collection, with at least one field
- Try to search for "Active User" in search bar
User will not be able to search by label should pass value thats "active" then only record comes
Expected behavior
User should be able to search by label also as Label is the only user can see.
Actual behavior
When you try to search by Label text no records will be returns though on UI label says "Active User" will not be able to search by this text.
Which area(s) are affected?
plugin: search
Environment Info
"payload": "3.80.0",
"@payloadcms/db-postgres": "3.80.0",
@payloadcms/next": "3.80.0",
"@payloadcms/plugin-cloud-storage": "3.80.0",
"@payloadcms/plugin-nested-docs": "3.80.0",
"@payloadcms/richtext-lexical": "3.80.0",
"@payloadcms/storage-azure": "3.80.0",
"@payloadcms/ui": "3.80.0",
"next": "15.4.11",
"react": "19.2.1",
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction repository and the CollectionConfig using listSearchableFields, then trace the search plugin's handling of select options. Verify the existing value search and add coverage for a label query such as “Active User”; done means both the label and stored value return the matching record.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100