feat(metadata-admin): page variable source is a component picker (#2328) - #2523
Merged
Conversation
A page variable's `source` (the component that writes it) rendered as a plain text input, forcing authors to type a component id by hand. Add a `ref:component` widget that offers a dropdown of the component ids on the page's canvas — mirroring the sibling `object` `ref:object` picker. - `collectPageComponentIds()` walks the draft `regions[].components[]` tree (nested containers included), de-duped in document order; free-text fallback when the page has no components, stale/renamed ids preserved. - `WidgetContext.componentIds` fed from the live page draft in ResourceEditPage. - Pairs with the framework page.form.ts change pinning `widget: 'ref:component'`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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.
Problem
When editing a Page in Studio, the
sourcefield under Variables (Data Context) rendered as a plain text<Input>— the author had to know and type a componentid(e.g.project_picker). The siblingobjectfield already renders as a dropdown (ref:object), establishing the expected UX.Fixes #2328.
What changed
New
ref:componentwidget (widgets.tsx):collectPageComponentIds(draft)— walks the page draft'sregions[].components[]tree, including nested containers (components/children, direct or underproperties), returning{ id, type, label }de-duped in document order.<Select>of those ids. Degrades to a free-text input when the page has no components yet, and preserves a stale/renamed id (shown with a(not in object)tag) so it's never silently dropped.WIDGETSand handled in the master-detailRowCellfor parity withref:object.Context wiring:
WidgetContextgainscomponentIds.ResourceEditPagederivescomponentIdsfrom the live draft (page type only) so components added on the canvas appear in the picker immediately.i18n:
selectComponent/noComponents(en + zh).Companion
Pairs with framework PR objectstack-ai/objectstack#2968, which pins
widget: 'ref:component'on the pagevariables.sourcesub-field. Merge framework first — until it deploys, this widget is dormant (no CI coupling; the wiring is runtime via the served/meta/typesform).Testing
RefComponentWidget.test.tsx— 9 tests: widget rendering (available / empty / stale-value),collectPageComponentIds(nesting, de-dup, skip-no-id, empty), and a fullSchemaFormintegration test proving a repeatersourcesub-field withwidget: 'ref:component'routes to the dropdown fed bycomponentIds.pnpm --filter @object-ui/app-shell type-checkclean.Screenshot / behavior
Opening a Page with an
element:record_picker(id="project_picker") and adding a variable now shows asourcedropdown listingproject_pickerand any other component ids on the page, instead of a free-text input.🤖 Generated with Claude Code