Description
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
- Create a collection with an Array field containing nested fields
- Set
disableListFilter: true
on one or more nested fields within the array - Navigate to the collection's list view in the admin panel
- Click on the "Filter" dropdown
- 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
- Using
hidden: true
instead - this works but completely hides the field rather than just removing it from filters - Using
condition: () => false
- this also hides the field completely - Moving the field outside of the array - this makes
disableListFilter
work correctly
Possible Related Issues
- Local API showHiddenFields does not work with nested fields #408 - Local API showHiddenFields does not work with nested fields
- Add support for virtual fields nested in arrays / blocks #12932 - Add support for virtual fields nested in arrays / blocks
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
- Create a collection with an Array field containing nested fields
- Set
disableListFilter: true
on one or more nested fields within the array - Navigate to the collection's list view in the admin panel
- Click on the "Filter" dropdown
- 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