Repository navigation
Description
Bug
A "type": "select" field's WordPress attribute schema is registered as type: 'object' with a {value, label} default — but the value actually serialized into the saved block comment (and returned by parse_blocks()) is a plain string matching one of options[].value. Since a plain string fails type: 'object' schema validation, WordPress core's WP_Block_Type::prepare_attributes_for_render() silently discards the stored value and substitutes the registered default. The render callback therefore always receives the default option, never whatever was actually selected/stored, regardless of post_content.
This also cascades in the block editor: on any block instance that includes at least one select-type field, every other attribute on that same block (plain text/textarea fields with correctly-typed schemas) fails to hydrate into the Inspector sidebar — fields show blank even though the real data exists in the database and renders correctly elsewhere — and edits typed into those blank fields are not persisted on save (confirmed: a typed value appears live in the canvas preview, but is absent from post_content after clicking Update).
Steps to reproduce
- A block with a select field and an unrelated text field:
{
"$schema": "https://blockstudio.dev/schema/block",
"name": "acme/example",
"title": "Example",
"category": "text",
"blockstudio": {
"attributes": [
{ "id": "heading", "type": "text", "label": "Heading" },
{ "id": "side", "type": "select", "label": "Side", "options": [
{ "value": "left", "label": "Left" },
{ "value": "right", "label": "Right" }
], "default": "right" }
]
}
}<?php
// index.php
echo '<div useBlockProps>heading=' . esc_html($a['heading'] ?? '') . ' side=' . esc_html($a['side'] ?? '') . '</div>';- Create a page whose
post_contentis:<!-- wp:acme/example {"heading":"Hello","side":"left"} /--> - View the page on the frontend.
- Open the page in the block editor and select the block.
Expected
- Frontend:
side=left. - Editor: Inspector shows "Hello" in the Heading field and "Left" selected in Side.
Actual
- Frontend always renders
side=right(the schema default), neverleft, no matter what's stored. - Editor Inspector shows both fields blank/empty — including Heading, despite its own schema being correctly typed
string. - Typing a new value into Heading and clicking Update does not change
post_content— the edit is silently lost. (Saving an untouched page is safe — only the typed edit itself disappears.)
What I verified
WP_Block_Type_Registry::get_registered('acme/example')->attributes['side']→['type' => 'object', 'field' => 'select', 'options' => [...], 'default' => ['value' => 'right', 'label' => 'Right'], ...]. The equivalentheadingtext field correctly registers as['type' => 'string', 'field' => 'text', ...].parse_blocks($post->post_content)returns the correct plain string ('side' => 'left') — WP core's comment parser is fine; the problem is downstream, at render/REST-attribute-sanitization time.render_block(['blockName' => ..., 'attrs' => ['side' => 'left', ...]])still resolves to'right', both with a plain string and with the{value, label}object passed directly — reproduced the same way against a real saved page withglobal $post/setup_postdata()/apply_filters('the_content', ...), not just a synthetic call.- In the editor,
wp.data.select('core/block-editor').getBlocks()shows the top-levelattributes.sidealready coerced to{value: 'right', label: 'Right'}(the default), and a parallelattributes.blockstudio.attributesobject — the one the Inspector sidebar panel actually reads from — with every field blank, includingheading, which is a plain string at the top level. - No related JS console errors.
- Bisected across the full release history: 7.0.0 (first GitHub release), 7.4.0, 7.7.13, and 7.7.14 (latest) all reproduce identically. This is not a regression — it's present as far back as there's a version to test.
- Workaround: declaring the field as
"type": "text"instead of"type": "select"avoids the broken schema registration entirely (plain text fields register correctly astype: 'string'), at the cost of losing the dropdown UI — the author has to type a valid value from a documented list instead of picking one. No data migration was needed in our case, since the values already stored inpost_contentwere plain strings matching the options'value.
Environment
- Blockstudio 7.7.13, also reproduced on 7.0.0, 7.4.0, 7.7.14
- WordPress 7.1.4, PHP 8.3.23 (live Local by Flywheel site) and PHP 8.5.12 (WP-CLI) — identical behavior on both
- Classic (GeneratePress child) theme, file-based blocks under
blockstudio/blocks/<name>/, standard Gutenberg comment-delimited blocks (not<block>tag patterns)
Suspected cause
The attribute schema generated for a select field mirrors the shape the editor UI keeps in its own React state ({value, label}, so the sidebar can show a label without re-deriving it from options), but the value actually written into the saved block comment is the plain value string. WordPress core's attribute-schema validation (used both in WP_Block::render()'s prepare_attributes_for_render() and in the editor's own attribute parsing) treats that mismatch as invalid and falls back to the registered default — so the real stored selection can never survive a normal save→render round trip, and the mismatch appears to poison the editor's blockstudio.attributes mirror for the whole block, not just the offending field.
Happy to share the exact test block/page and the editor JS state dump if useful.
Activity
chechman commentedon Nov 11, 2026
Follow-up with something that may help narrow this down: the broken top-level schema validation turns out to be avoidable entirely by including the editor's own
"blockstudio":{"attributes":{...}}mirror alongside the flat attrs in the saved comment, e.g.:With that mirror present,
render_block()resolvessideto'left'correctly — the broken top-leveltype: objectschema validation is bypassed entirely, presumably because the render path reads fromblockstudio.attributeswhen it's present rather than the WP-core-sanitized top-level attrs.This also explains a second, related problem we ran into: any block comment built without that mirror (e.g. written programmatically, not through the editor) has every field — not just select fields — show blank in the Inspector sidebar, and typed edits into those blank fields don't persist on save. Adding the mirror to our own generated content fixed both issues at once. Mentioning it here in case it's useful context for tracking down the actual validation/rendering code path, or worth documenting as the expected comment shape for anything that writes Blockstudio block content outside the editor.
dnnsjsk commentedon Nov 12, 2026
@chechman
Could you try this version and let me know if it works for you:
https://packagist.org/packages/blockstudio/blockstudio#7.7.15.x-dev
dnnsjsk commentedon Nov 23, 2026
Released in Blockstudio 7.7.15, via #209. Flat field values in imported block comments, including saved select values, now work in rendering and in the editor. Saving subsequent edits uses the existing
blockstudio.attributesformat. No migration is needed for existing content.chechman commentedon Nov 23, 2026
Can confirm 7.7.15 fixes this for me ✅
Thanks for the quick turnaround on this!