feat(spec): add SelectOption.visibleWhen; generalize Field.dependsOn (objectui#2284)#2635
Merged
Merged
Conversation
…(objectui#2284)
Add a per-option CEL visibility predicate `SelectOption.visibleWhen` for
select/multiselect/radio fields — the option is offered only when TRUE,
evaluated against the live record + `current_user` (same binding environment as
a field-level `visibleWhen`). Expresses cascading/dependent options
(`record.country == 'cn'`) and role/context gating
(`'admin' in current_user.roles`) without a bespoke dependent-picklist matrix.
Shared by `Field.options` and view `FormField.options`. Generalize the
`Field.dependsOn` description to be mechanism-neutral (declares dependent
sibling fields for both lookup candidate-scoping and select option gating);
`{field,param}` stays lookup-only.
Client-side hiding is UX only — authorization-gated values must be rejected
server-side by the rule-validator.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aYFm77ddLp6tzuJjt9hK2
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 94 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
marked this pull request as ready for review
July 5, 2026 13:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spec change enabling cascading & role-gated
selectoptions in ObjectUI (objectstack-ai/objectui#2284). Companion renderer PR: objectstack-ai/objectui#2289.What
SelectOption.visibleWhen— a per-option CEL visibility predicate forselect/multiselect/radio. The option is offered only when TRUE, evaluated against the live record +current_user(same binding environment as a field-levelvisibleWhen). Expresses cascading/dependent options (record.country == 'cn') and role/context gating ('admin' in current_user.roles) without a bespoke dependent-picklist matrix. BecauseField.optionsand viewFormField.optionsshareSelectOptionSchema, both layers gain it from one change.Field.dependsOndescription generalized to be mechanism-neutral: it declares the sibling field(s) a field's available values depend on (gating + re-evaluation), for both lookups (candidate-query scoping) and selects (per-optionvisibleWhengating). The{field,param}form stays lookup-only. Type unchanged.Why this shape
A dependent-picklist matrix (
validFor/controllingField) is cascade-only and can't express role/tenant/context gating; it also adds a new serializable concept authors and AI must learn.dependsOn+visibleWhenare existing primitives — uniform with dependent lookups, maximally expressive (multi-field,current_user), and easy to author/read. See the design discussion in objectui#2284.Security
Client-side hiding is UX, not authorization — option
visibleWhenonly hides the choice in the UI; the value is still submittable. Authorization-gated values must also be rejected server-side (the rule-validator evaluates the picked value'svisibleWhen). Noted in the field doc-comment.Tests
Full
@objectstack/specsuite passes (6700).SelectOptionSchemagains an optional field (backward-compatible);pnpm buildsucceeds.🤖 Generated with Claude Code
https://claude.ai/code/session_019aYFm77ddLp6tzuJjt9hK2
Generated by Claude Code