Skip to content

fix: filter CMS reference sub-options by allowed field types#82

Merged
liamwalder merged 2 commits intodevelopfrom
fix/cms-option-filtering
Mar 24, 2026
Merged

fix: filter CMS reference sub-options by allowed field types#82
liamwalder merged 2 commits intodevelopfrom
fix/cms-option-filtering

Conversation

@tristan-mouchet
Copy link
Copy Markdown
Collaborator

@tristan-mouchet tristan-mouchet commented Mar 23, 2026

Summary

Reference fields in CMS option dropdowns were showing all sub-options regardless of the type filter applied at the root level. For example, a rich-text field selector would show a reference group containing text, number, boolean fields instead of only rich-text fields.

Changes

  • Add referenceHasMatchingSubFields recursive helper to filterFieldGroupsByType — reference fields are now excluded when their referenced collection has no matching sub-fields (cycle-safe, checks recursively through nested references)
  • Add allFields option to filterFieldGroupsByType to enable reference sub-field checking at the data level
  • Sort reference fields to the end of each group
  • Update CollectionFieldSelector to derive effective allowed types from pre-filtered incoming groups and aly a single filterFieldGroupsByType pass with allFields — fixes all consumers automatically with no call-site changes
  • Fix FieldSelectDropdown to pass allFields to its own filter call
  • Remove unused CollectionFieldList component and collectionLabel prop

Test plan

Add 2 collections, one having a reference field to the other collection.

  • Open a rich-text layer in the sidebar → Content field CMS dropdown should only show rich_text fields (and references that contain rich-text sub-fields)
  • Open an image layer → image CMS dropdown should only show image fields
  • Open link settings → field dropdown should only show link-type fields
  • Expand a reference group — sub-options should match the same type filter as root level
  • Reference groups wihing sub-options should not appear at all
  • References should appear after regular fields in every dropdown

@liamwalder liamwalder merged commit 5e9cb81 into develop Mar 24, 2026
2 checks passed
@liamwalder liamwalder deleted the fix/cms-option-filtering branch March 24, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants