concrete/render/group-ancestry
An object's field is marked outside its own `Slot.Object`.
An object's field is marked outside its own Slot.Object.
Graded by the render stage of concrete check, in the render venue. A violation reports this id and the file it failed at — see every rule and concrete check.
Reason
An object's field is addressed through the object: the editor reads the field's marker,
finds the nearest object marker around it — the top-level object's container, or the
item's — and edits that object's field. The marker contract
has no second channel for that: which object a field belongs to is where its marker
landed. So a field rendered outside its own Slot.Object — after the container, or inside
another slot's element — resolves to the wrong card or to none, and the sidebar loses the
field exactly where that copy renders.
The types cannot see this: a field's binding renders anywhere a primitive does. Only
concrete check catches it, by rendering the section over every fixture and reading each
field marker's ancestry as the editor does.
Fix
Render every field of an object inside that object's Slot.Object, through the field's
own binding: slot.address.city inside <Slot.Object slot={slot.address}>, and
item.price inside <Slot.Object slot={item}>. A copy that has to live elsewhere
in the markup renders with selectable={false}: it keeps its identity and its live
patching, and it is no longer an editing target competing with the one in the object.
Before and after
import { compute, fact, object, Section, section, Slot, text } from "@homepages/concrete";
export const Sheet = section(
{
key: "sheet",
label: "Fact sheet",
slots: {
address: object({
label: compute(() => "Property address"),
fields: {
street: text.short({ label: "Street", source: fact.property.address.street }),
city: text.short({ label: "City", source: fact.property.address.city }),
},
}),
},
},
({ slot }) => (
<Section>
<Slot.Object slot={slot.address} as="address">
<Slot.Text slot={slot.address.street} as="span" />
</Slot.Object>
{/* The city is a field of the address, marked outside it. */}
<Slot.Text slot={slot.address.city} as="p" />
</Section>
),
);import { compute, fact, object, Section, section, Slot, text } from "@homepages/concrete";
export const Sheet = section(
{
key: "sheet",
label: "Fact sheet",
slots: {
address: object({
label: compute(() => "Property address"),
fields: {
street: text.short({ label: "Street", source: fact.property.address.street }),
city: text.short({ label: "City", source: fact.property.address.city }),
},
}),
},
},
({ slot }) => (
<Section>
<Slot.Object slot={slot.address} as="address">
<Slot.Text slot={slot.address.street} as="span" />
<Slot.Text slot={slot.address.city} as="span" />
</Slot.Object>
</Section>
),
);