You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ui): virtual fields disappearing from filter/groupBy dropdowns with access control (#14514)
### What?
Virtual fields with `virtual: string` syntax (e.g., `virtual:
'post.title'`) were disappearing from the filter (WhereBuilder) and
groupBy dropdowns when the collection had at least one field with custom
`access.read` control.
### Why?
The bug was introduced in commit `bcd40b6df7` which added permission
checks to hide fields with `read: false`. The implementation had two
problems:
1. **Permission check failure**: The code was setting `field.name = ''`
for virtual fields BEFORE checking permissions. This caused
`fieldPermissions?.[field.name]` to become `fieldPermissions?.['']`
which evaluated to `undefined`, failing the permission check and hiding
all virtual fields.
2. **Object mutation bug**: The field object is shared across multiple
components (WhereBuilder, GroupByBuilder, etc.). Mutating `field.name =
''` affected all components that used the same field object, breaking
permission checks and field path construction everywhere.
### How?
The fix eliminates the mutation entirely:
- Instead of mutating `field.name = ''`, we now use a flag
`shouldIgnoreFieldName` to track whether to include the field name in
the path
- The original `field.name` is preserved throughout, ensuring permission
checks work correctly: `fieldPermissions?.[field.name]`
- The field path is constructed conditionally based on the
`shouldIgnoreFieldName` flag
This ensures:
- Permission checks always have access to the correct field name
- The shared field object is never mutated
- Virtual fields appear in dropdowns when they should
- Virtual fields with `access.read: false` are properly hidden
Added e2e tests covering:
- Virtual fields in filter and groupBy dropdowns with access control
present
- Virtual group fields with nested fields
- Virtual fields nested inside groups
- Virtual fields with `access.read: false` (properly hidden)
0 commit comments