Skip to content

fix(collection table): support conditional fields in columns schema#1545

Open
Punith1117 wants to merge 1 commit into
Thinkmill:mainfrom
Punith1117:fix/conditional-field-columns-object-rendering
Open

fix(collection table): support conditional fields in columns schema#1545
Punith1117 wants to merge 1 commit into
Thinkmill:mainfrom
Punith1117:fix/conditional-field-columns-object-rendering

Conversation

@Punith1117

Copy link
Copy Markdown

Summary

This PR fixes two issues when using fields.conditional() in collection columns:

  1. Conditional fields were rejected by TypeScript when referenced in a collection's columns array.
  2. Conditional field values were rendered as [object Object] in the collection list view.

Changes

TypeScript support

Updated the collection() column type definition to allow ConditionalField entries in addition to the previously supported field types.

Runtime rendering

When rendering collection table values, conditional field values are now detected and their discriminant value is displayed instead of coercing the entire object to a string.

Before:
[object Object]

After:
true or false

(or the selected discriminant value for select-based conditional fields).

Testing

Tested with conditional fields using:

  • Checkbox discriminants (true / false)
  • Select discriminants with multiple options

Verified that:

  • Conditional fields can be added to columns without TypeScript errors.
  • Collection list views render the selected discriminant value instead of [object Object].
  • Existing supported column types continue to behave as before.

Implementation Notes

While investigating this issue, it became apparent that collection column rendering currently assumes that all column values have a scalar preview representation.

Conditional fields are one of the first structured field types where this assumption breaks. Their stored value is an object, which results in [object Object] being rendered when the value is coerced to a string.

For this fix, the conditional field's discriminant value is used as the column preview because it provides a meaningful scalar representation of the selected condition.

More generally, it may be safer for collection columns to explicitly support only scalar-like field types (and other field types that provide a well-defined preview value) rather than attempting to stringify arbitrary complex structures such as object, image, file, markdoc, or mdx fields.

A more comprehensive long-term solution could be a field-level preview resolver that allows each field type to define how it should be represented in collection columns. However, that appears to be a broader design change and is outside the scope of this PR.

Related

Fixes #1396

- Convert conditional field values to their discriminant string when rendering table columns to avoid [object Object] output.
- Update column schema typing to include ConditionalField so it can be used in collection column definitions.
@Punith1117 Punith1117 requested a review from emmatown as a code owner June 5, 2026 10:40
@changeset-bot

changeset-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0e5c6c9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

Adding a conditional field to columns result in [object Objeect] being rendered

1 participant