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
I read "follow-up" as "follow-up PR" but want to confirm before opening one — opening this discussion in the Ideas category to match the CONTRIBUTING.md process for features.
Proposal
Add conditional sub-field visibility (visibleWhen) to the object-form and list widgets in @emdash-cms/plugin-field-kit. Sub-fields can declare a rule that hides them when a sibling value doesn't match — e.g. show Cooking time only when Cooked? is checked.
Four operators, all using strict equality (so equals: 1 does not match "1"):
Operator
Matches when…
equals
sibling is strictly equal
notEquals
sibling is not strictly equal
in
sibling is one of the listed values
notIn
sibling is not in the list
Behaviour
Values persist across toggles. Hidden fields stay in the DOM (display: none + aria-hidden) so values round-trip through save and reappear when the condition flips back. A user can toggle a flag on, fill the dependent field, toggle off, and toggle on again — the value is still there.
required is stripped while hidden so HTML5 validation can't block save on a field the user can't see. The required asterisk reappears with the field.
list evaluates per-row — row A can show a sub-field that row B hides.
Sibling lookup only.visibleWhen.field references another sub-field within the same object-form (or list row), not a top-level collection field.
Code is ready
Implementation is on a single-commit branch off latest main, ready to PR once approved here:
What's in it (10 files, all in packages/plugins/field-kit/ or its docs):
5 source files implementing VisibleWhenCondition, the isSubFieldVisible evaluator, hidden-aware rendering in SubField, and per-row sibling context wiring in list / object-form
3 test files: 6 unit tests for isSubFieldVisible, 4 new object-form tests, 1 new list test
1 docs update: new Conditional visibility (visibleWhen) subsection on the existing field-kit.mdx reference page
1 changeset: @emdash-cms/plugin-field-kit: minor
pnpm typecheck and pnpm test are green (44 plugin tests pass).
Demo
Re-shared from the original prototype on ilicfilip/field-kit#2 — same feature, same behaviour, recorded against a recipe schema with calories, protein, source, organic, on sale, ingredients sub-fields:
Screen.Recording.2026-04-17.at.16.58.40.mov
Asking
@ascorbic — does this match what you had in mind for the follow-up? Happy to:
Open the PR directly against main if "follow-up" meant follow-up PR (my read of your earlier comment), or
Iterate on the proposal here first if you'd prefer to discuss before code review.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Background
Following up on the agreed
visibleWhenwork mentioned in discussion #571:I read "follow-up" as "follow-up PR" but want to confirm before opening one — opening this discussion in the Ideas category to match the CONTRIBUTING.md process for features.
Proposal
Add conditional sub-field visibility (
visibleWhen) to theobject-formandlistwidgets in@emdash-cms/plugin-field-kit. Sub-fields can declare a rule that hides them when a sibling value doesn't match — e.g. show Cooking time only when Cooked? is checked.{ "key": "cooking_time", "label": "Cooking time", "type": "number", "visibleWhen": { "field": "cooked", "equals": true } }Operators
Four operators, all using strict equality (so
equals: 1does not match"1"):equalsnotEqualsinnotInBehaviour
display: none+aria-hidden) so values round-trip through save and reappear when the condition flips back. A user can toggle a flag on, fill the dependent field, toggle off, and toggle on again — the value is still there.requiredis stripped while hidden so HTML5 validation can't block save on a field the user can't see. The required asterisk reappears with the field.listevaluates per-row — row A can show a sub-field that row B hides.visibleWhen.fieldreferences another sub-field within the sameobject-form(or list row), not a top-level collection field.Code is ready
Implementation is on a single-commit branch off latest
main, ready to PR once approved here:ilicfilip:feat/field-kit-visible-whenWhat's in it (10 files, all in
packages/plugins/field-kit/or its docs):VisibleWhenCondition, theisSubFieldVisibleevaluator, hidden-aware rendering inSubField, and per-row sibling context wiring inlist/object-formisSubFieldVisible, 4 newobject-formtests, 1 newlisttestConditional visibility (visibleWhen)subsection on the existingfield-kit.mdxreference page@emdash-cms/plugin-field-kit: minorpnpm typecheckandpnpm testare green (44 plugin tests pass).Demo
Re-shared from the original prototype on
ilicfilip/field-kit#2— same feature, same behaviour, recorded against a recipe schema withcalories,protein,source,organic,on sale,ingredientssub-fields:Screen.Recording.2026-04-17.at.16.58.40.mov
Asking
@ascorbic — does this match what you had in mind for the follow-up? Happy to:
mainif "follow-up" meant follow-up PR (my read of your earlier comment), orEither way the branch is rebased and ready.
Beta Was this translation helpful? Give feedback.
All reactions