Skip to content

disableListFilter does not work for nested fields in Array fields #12978

Open
@Exia081

Description

@Exia081

Describe the Bug

disableListFilter does not work for nested fields in Array fields

🐛 Bug Report

Description

The disableListFilter admin property does not take effect when applied to nested fields within Array fields. Despite setting disableListFilter: true, these fields still appear in the list view filter options.

Expected Behavior

When disableListFilter: true is set on a field nested within an Array field, that field should not appear in the list view filter dropdown options.

Actual Behavior

The disableListFilter: true setting is ignored for nested fields within Array fields, and these fields still appear in the filter options in the list view.

Steps to Reproduce

  1. Create a collection with an Array field containing nested fields
  2. Set disableListFilter: true on one or more nested fields within the array
  3. Navigate to the collection's list view in the admin panel
  4. Click on the "Filter" dropdown
  5. Observe that the nested fields with disableListFilter: true still appear in the filter options

Code Example

export const Question: CollectionConfig = {
  slug: 'questions',
  fields: [
    {
      name: 'options',
      type: 'array',
      fields: [
        {
          name: 'id',
          type: 'text',
          admin: {
            disableListFilter: true, // This should prevent the field from appearing in filters
          },
        },
        {
          name: 'description',
          type: 'text',
          admin: {
            disableListFilter: true, // This should also be hidden from filters
          },
        },
        // ... other fields
      ],
    },
  ],
}

Environment

  • Payload version: 3.44.0
  • Node.js version: v22.14.0
  • Database: PostgreSQL
  • Operating System: macOS

Additional Context

This issue appears to be related to how Array fields handle admin properties for their nested fields. Similar issues have been reported for other admin properties like showHiddenFields not working properly with nested fields (see #408).

Workarounds Attempted

  1. Using hidden: true instead - this works but completely hides the field rather than just removing it from filters
  2. Using condition: () => false - this also hides the field completely
  3. Moving the field outside of the array - this makes disableListFilter work correctly

Possible Related Issues

Suggested Fix

The issue likely stems from the Array field's rendering logic not properly inheriting or applying admin configurations for nested fields. The admin properties should be respected for all nested fields within Arrays, Blocks, and other container field types.

Link to the code that reproduces this issue

pnpm run devsafe

Reproduction Steps

Steps to Reproduce

  1. Create a collection with an Array field containing nested fields
  2. Set disableListFilter: true on one or more nested fields within the array
  3. Navigate to the collection's list view in the admin panel
  4. Click on the "Filter" dropdown
  5. Observe that the nested fields with disableListFilter: true still appear in the filter options

Which area(s) are affected? (Select all that apply)

area: ui

Environment Info

### Environment
- **Payload version**: 3.44.0
- **Node.js version**: v22.14.0
- **Database**: PostgreSQL
- **Operating System**: macOS

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions