Problem/Motivation

First, thanks for the amazing work thus far! We have been working extensively with SDC in general with our site building process that leverages Layout Paragraphs and Mercury Editor. Both of those modules add properties to the build array that are required for functionality, including attached libraries, attributes, and pre-/post-render objects.

When enabling SDC Display and attempting to map field values to props and slots, we encountered lots of issues that prevented Layout Paragraphs from functioning correctly (and by extension, Mercury Editor). If we used vanilla Paragraphs, things seemed to work fine.

Steps to reproduce

  • Enable Paragraphs, Layout Paragraphs, and SDC Display.
  • Create a Paragraph type with some fields.
  • Create a content type with a Paragraph reference field, and ensure the newly-created Paragraph can be added.
  • Create a component with props/slots to display the fields from the Paragraph type.
  • Edit the display of the Paragraph type, render using the component, and map the fields from the Paragraph type to the props in the component.
  • At this point, the Paragraph should render using the component, and it should be editable.
  • Switch the Paragraph reference field on the content type to use Layout Paragraphs in the display and the form display.
  • Now you should be able to add a new Paragraph to the page, but weirdness happens if you save the node, and the editor controls for Layout Paragraphs do not appear so content cannot be edited.

Proposed resolution

This seems to happen because many existing properties in the build array are obliterated in sdc_display_entity_view_alter(). Propose leaving the build array as it stands, and only altering it by inserting the component props and slots, and removing fields that have been mapped to those props/slots.

Remaining tasks

The submitted MR endeavors do provide that resolution, but it has definitely not been tested across a variety of scenarios. It seemed to make Layout Paragraphs more compatible with SDC Display, but this approach may introduce new trouble with other modules or build approaches.

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

sethhill created an issue. See original summary.

sethhill’s picture

Status: Active » Needs review
sethhill’s picture

Title: Entity view alter removes properties from build array » Entity view alter removes needed properties from build array
pcambra’s picture

Version: 1.x-dev » 2.x-dev
pcambra’s picture

Status: Needs review » Needs work
idflood’s picture

I was testing mercury and and was sad to see it didn't work with sdc. So thanks a lot sethhill for this patch, it's working fine now

grumpydev74’s picture

The patch seems to work. Thanks for this sethhill

johnny5th’s picture

This also seems to work for me! Thanks!

grgcrlsn321 made their first commit to this issue’s fork.

grgcrlsn321’s picture

Status: Needs work » Needs review

Merged in 2.x-dev branch code and changed the for loop to unset build component to use Element class as suggested. Needs review.

grgcrlsn321 changed the visibility of the branch 3452441-entity-view-alter to hidden.

grgcrlsn321 changed the visibility of the branch 3452441-entity-view-alter to active.

agarzola’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that the latest patch for the 2.x branch (MR !28) works for us. Paragraphs configured to render with SDCs show the + buttons above and below in Mercury Editor and also show contextual menus when the node is viewed, which is another piece of functionality that also gets lost when configuring Paragraphs to render via `sdc_display`.