Replies: 1 comment
|
Converted this to a discussion as it is a feature request. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
RepeaterElementis the only Block Kit element that captures more than onevalue, and its sub-fields are restricted to four scalar element types. A
content shape as ordinary as "a list of cases, each with a title and three
labelled rows" therefore has no typed representation: the block either flattens
to a fixed number of scalar sub-fields, or the whole region stays an opaque HTML
atom that the editor cannot touch.
Verified against
@emdash-cms/blocks@0.32.0, and re-checked unchanged in0.33.0(currentlateston npm).Where
The union, in
@emdash-cms/blockssrc/types.ts:It is enforced at runtime too, not only by types, in
src/validation.ts:message: `Repeater sub-field type '${sub.type}' is not allowed. Expected one of: …`Note that
media_pickeris a valid top-level element and is also excluded fromthat set, so a repeater of images is out of reach by the same rule. (#1424
added media support to the content-type repeater field; the Block Kit
repeater is a separate surface and did not change.)
Reproducing
TypeScript rejects the nested element, and forcing it past the types produces
Repeater sub-field type 'repeater' is not allowed.The interesting part: the renderer may already be closer than the types
In
@emdash-cms/adminsrc/components/PortableTextEditor.tsx, a repeater rowrenders each of its sub-fields through
BlockKitField— the same componentused at the top level of the modal, whose switch already has a
case "repeater"that delegates toBlockKitRepeater. So the row rendererwould dispatch a nested repeater today.
Two things in the same file would need attention before that worked:
handleAddseeds a new row from the sub-field type, withfalsefortoggle,undefinedfornumber_input, and""for everything else. Anested repeater would be seeded with a string rather than
[].stripKeysremoves_keyat one level only, so nested rows would keep thesynthetic keys the widget adds.
That is a reading of the source, not a test result — I did not force a nested
repeater through to see what the widget does with it.
Why it matters
The alternative shapes are worse in ways that show up in the editor:
row1_label,row1_value,row2_label… fixes the countat declaration time and produces a modal of eight or more unrelated inputs
with no visual grouping. It also silently caps the content.
the outcome the block API exists to avoid.
The shape is common: FAQ groups, comparison cases, timelines with sub-steps,
spec sheets. One level of nesting covers all of them.
Suggested fix
RepeaterElementinRepeaterSubField, bounded to one level ofnesting so the shape stays predictable and the widget stays simple. Add
"repeater"toREPEATER_SUB_FIELD_TYPES, seed nested rows as[]inhandleAdd, and recurse instripKeys.RepeaterSubFielddocstring. The current wording ("Limited to the scalar inputs the admin
widget currently renders inline") reads as a temporary implementation limit,
so plugin authors reasonably try it and hit the runtime error.
Happy to send a PR for (1) if you would like a particular shape.
All reactions