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",
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
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,
},
],
}
`
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