Skip to content

'listSearchableFields' does not support searching by select field labels (only values) #16349

@MeghaPurohit306

Description

@MeghaPurohit306

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

  1. Define a Field with an options array where label and values are different for options (or use the reproduction repo):
  2. `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,
},
],
}
`

  1. Open a document in the admin panel containing this collection, with at least one field
  2. 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",

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: search@payloadcms/plugin-searchstatus: needs-triagePossible bug which hasn't been reproduced yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions