Overview

Earlier today, I used the latest Drupal Forge demo to test something. While there, I tried adding a pattern of the entire area above the copyright area at the bottom that includes the Drupal logo, menus, and social media icons.

It left out the Drupal logo and one menu but everything else was included. I forgot to check the logs.

On phone, so can’t grab a screenshot but didn’t want to forget reporting this

Steps to reproduce

  1. Use the DF XB Demo: https://www.drupalforge.org/template/drupal-cms-xb
  2. Go to Layers and scroll down for Flexible Slot
  3. Use "..." and choose "Create pattern"
  4. Drag the pattern into the page
  5. Note that the Drupal logo and first menu are missing

SDDS XB original footer

SDDS XB creating pattern with original footer

SDDS XB adding footer pattern to page

SDDS XB added pattern is missing logo and menu

Proposed resolution

User interface changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kristen pol created an issue. See original summary.

kristen pol’s picture

That’s from the demo design system

wim leers’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

Looking forward to the additional info to reproduce this! 😊🙏

heyyo’s picture

I also saw this issue outside xb-demo, and I didn't have any region enabled in my theme to be managed by XB.

heyyo’s picture

StatusFileSize
new1.42 MB

I just checked, the POST request xb/api/v0/config/pattern doesn't contain the full tree of the selected component.

wim leers’s picture

Component: … to be triaged » Internal HTTP API

I see, so then … it must be a client-side problem? But the video in #6 does not show the request body, so it could still be the same back-end bug that causes the information the client sent to get lost 😅

I'm going to bet that this is a back-end bug, and just another symptom of #3534971-6: ApiLayoutController::getRegionForComponentInstance doesn't work well with nested components if there are multiple regions.. Bumping the priority of that one. Odd that this was found so late!

heyyo’s picture

StatusFileSize
new263.68 KB

right payload is ok, so backend issue.
payload create pattern

wim leers’s picture

Title: Created XB Pattern didn’t include all components » [PP-1] Created XB Pattern didn’t include all components
Status: Postponed (maintainer needs more info) » Postponed
Issue tags: -Needs steps to reproduce

Yeah then I'm 99% confident it's a duplicate of that other isssue. 😇

Let's first land that other issue, then test again here.

kristen pol’s picture

Issue summary: View changes
StatusFileSize
new435.16 KB
new233.15 KB
new230.26 KB
new475.07 KB
mayur-sose’s picture

StatusFileSize
new260.2 KB

I added several nested code components inside two-column components and created a pattern with them. However, I noticed that some components were not included in the resulting pattern. @wim-leers this issue is not resolved with #3534971

lauriii’s picture

Priority: Normal » Critical
Status: Postponed » Active
Issue tags: +beta target
lauriii’s picture

Title: [PP-1] Created XB Pattern didn’t include all components » Created XB Pattern didn’t include all components
wim leers’s picture

Too bad #3534971: ApiLayoutController::getRegionForComponentInstance doesn't work well with nested components if there are multiple regions. didn't solve it. It's the same fundamental problem.

In this case though, \Drupal\experience_builder\Controller\ApiConfigControllers::post() is what creates Pattern (and other) XB config entities. That calls Pattern::createFromClientSide(), which ends up calling \Drupal\experience_builder\Controller\ClientServerConversionTrait::convertClientToServer().

Apparently ApiLayoutController contains an alternative implementation of fundamentally the same logic 😞 That's been a known issue for months. We've been prioritizing new features over refactoring/cleaning up, so I'm not surprised we never got to those.

My latest thinking and write-up about this was … on February 20 (almost 5 months ago!!!) at #3503239-4: [PP-1] Make use of the serializer for normalizing/denormalizing config entities in ApiConfigControllers.

thoward216’s picture

Assigned: Unassigned » thoward216
thoward216’s picture

I've started some investigation into this and it doesn't look to be the same issue as #3534971 and looks to be due to #3526127 and the way that the function generateComponentTreeKeys() builds the keys.

The array that is passed into the generateComponentTreeKeys() function contains all 10 items in the tree in my case, but when I go through the function I only end up with 8 items.

I did a test by commenting out the set() function in Pattern entity and everything saves as expected so that looks to prove where the root cause looks to be. Will continue to debug this further.

larowlan’s picture

Assigned: thoward216 » larowlan

Will try to move this along a bit while @thoward216 sleeps 🧚‍♀️

larowlan’s picture

Version: 0.x-dev » 1.x-dev
larowlan’s picture

larowlan’s picture

Title: Creating an XB Pattern loses some component instances » Creating an XB Pattern or ContentTemplate loses some component instances

As the bug is in \Drupal\experience_builder\Plugin\Field\FieldType\ComponentTreeItemListInstantiatorTrait::generateComponentTreeKeys, this also impacts ContentTemplates - new title

larowlan’s picture

Component: Internal HTTP API » Config management
Assigned: larowlan » thoward216
Status: Active » Needs review

Pushed a fix with some expanded docs of what is going on in that method.

thoward216’s picture

Thanks @larowlan - I've manually tested this and everything is working as expected and the output of the component tree keys is what I was expecting to see also. I've just opened an MR to run the pipeline.

larowlan’s picture

Whoops I forgot that, thanks

thoward216’s picture

Assigned: thoward216 » Unassigned
isholgueras’s picture

I've left some minor comments. Overall, It looks good to me though

wim leers’s picture

Assigned: Unassigned » thoward216
Status: Needs review » Needs work

Test-only CI job failed 👍

Requested a few clarifications, specifically around the continue — I'm not convinced yet it is necessary. It's better to fail explicitly than silently ignore problems — unless there's a good reason, and then that should be documented 🙏

thoward216’s picture

Assigned: thoward216 » Unassigned
Status: Needs work » Needs review
wim leers’s picture

Assigned: Unassigned » wim leers
wim leers’s picture

Title: Creating an XB Pattern or ContentTemplate loses some component instances » Bug in `generateComponentTreeKeys()` causes XB config entity containing a component tree to loses some component instances upon creation
Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community
Issue tags: +data loss, +backport

AFAICT this could also affect PageRegions, because that's the third config entity type that relies on \Drupal\experience_builder\Plugin\Field\FieldType\ComponentTreeItemListInstantiatorTrait::generateComponentTreeKeys()

This boils down to data loss, so … tagging backport.

wim leers’s picture

After writing #30, one thing didn't sit right: we're only adding test coverage for Pattern, but per @larowlan in #20, this affects ContentTemplates too, and per my #30, PageRegions too.

We should test all 3, generically. Made it so.

wim leers’s picture

IOW this was a bug in #3526127: Ensure deterministic config export order of config-defined component trees — the test coverage that that added and this issue expanded has now been generalized using a new \Drupal\Tests\experience_builder\Kernel\Config\ConfigWithComponentTreeTestBase.

I expect linting errors but tests to pass — will fix after lunch 👍

wim leers’s picture

Assigned: Unassigned » balintbrews
Status: Reviewed & tested by the community » Patch (to be ported)
wim leers’s picture

@lauriii confirmed the backporting of this to 0.x in Slack :)

balintbrews’s picture

Assigned: balintbrews » Unassigned
Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.