Problem/Motivation
The demo_umami install profile ships with default content to populate the site. The profile configuration ships with this for the 'full' mode of the Recipe node entity view display:
-
layout_id: layout_oneplusfourgrid_section
layout_settings:
label: ''
components:
cc87463d-bb75-4eca-a2d0-42f0b643f8a7:
uuid: cc87463d-bb75-4eca-a2d0-42f0b643f8a7
region: content
configuration:
id: 'field_block:node:recipe:field_media_image'
label: 'Media Image'
label_display: '0'
provider: layout_builder
context_mapping:
entity: layout_builder.entity
view_mode: view_mode
formatter:
type: entity_reference_entity_view
label: hidden
settings:
view_mode: responsive_3x2
third_party_settings: { }
weight: 4
additional: { }
Only... according to the custom Layout plugin in Umami, the 'content' region does not exist:
layout_oneplusfourgrid_section:
label: 'One plus four grid'
path: layouts/oneplusfourgrid_section
template: layout--oneplusfourgrid-section
library: umami/oneplusfourgrid_section
category: 'Custom grid'
default_region: first
icon_map:
- [first, second, third]
- [first, fourth, fifth]
regions:
first:
label: First
second:
label: Second
third:
label: Third
fourth:
label: Fourth
fifth:
label: Fifth
The 'content' region is indeed stored in the field value, making it impossible to remove from it. When reading out JSON:API content for Layout Builder (
π
[PP-1] Expose Layout Builder data to REST and JSON:API
Postponed
) you will see it fed back to you:
This is problematic when trying to sort and order the regions and components for JSON:API. There is no way to know from the frontend that this is either an invalid block or invalid configuration given this region doesn't actually exist.
Steps to reproduce
Install Umami profile, view the field data for an overridden layout for Recipes or the default managed layout. The 'content' region will exist in the mentioned Layout plugin that should not exist.
Proposed resolution
Validate the data before saving. If the region does not exist in the layout it is in, remove the block from the data before saving, and alert the user that the block was removed and needs to be re-added and or, the data is invalid and cannot be saved. In either case there needs to be recovery and a way to adjust it.