Skip to content

listSearchableFields: a nested array path searches correctly but the box says "Search by ID" (3.x) #18201

Description

@mishery97

Describe the Bug

admin.listSearchableFields accepts a dotted path to a field inside an array (e.g. ['submissionData.value'] on the form-builder plugin's form-submissions). The search itself works — mergeListSearchAndWhere maps each configured string straight to { [path]: { like: search } }, and a dotted path is a valid query path — but the search box's placeholder doesn't know the field: it falls back to the title field and reads "Search by ID", telling the user it searches the row id when it searches what they typed.

Cause: getTextFieldsToBeSearched flattens the collection's fields with flattenTopLevelFields(fields, { moveSubFieldsToTop: true }), which descends into group, tabs, row and collapsible fields but never arrays, and then matches the configured strings against the bare field.name. 'submissionData.value' matches nothing.

Link to the code path

3.x:

  • packages/ui/src/elements/ListControls/getTextFieldsToBeSearched.ts (whole file — the searchableFieldNames.has(field.name) match)
  • packages/ui/src/elements/ListControls/index.tsx builds the placeholder from its result
  • packages/payload/src/utilities/mergeListSearchAndWhere.ts (the search that does work)

On main the placeholder is simplified to plain "Search" (ListControls/index.tsx, "Simplified placeholder"), so this only affects 3.x.

Reproduction Steps

  1. Any collection with an array field holding a text subfield, e.g.
    fields: [{ name: 'items', type: 'array', fields: [{ name: 'value', type: 'text' }] }],
    admin: { listSearchableFields: ['items.value'] },
    (form-submissions from @payloadcms/plugin-form-builder with listSearchableFields: ['submissionData.value'] is the real case.)
  2. Open the list view. The search box says "Search by ID".
  3. Type text that appears in items.value → the rows filter correctly.

Confirmed on 3.86.0 and, by reading the source, 3.89.0.

Expected Behavior

The placeholder names the field(s) actually searched ("Search by Value"), or at least doesn't claim "ID".

Actual Behavior

"Search by ID" while the search matches the array subfield.

Proposed fix

Resolve dotted paths in getTextFieldsToBeSearched: match against each flattened field's full path (and descend array fields), or, as main does, drop the field list from the placeholder.

Environment

  • Payload 3.86.0 (confirmed in the admin), 3.89.0 (source read)
  • @payloadcms/plugin-form-builder, @payloadcms/db-postgres, Next.js 16

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions