When an entity is embedded and you quick edit the parent entity, the title field of the parent and the title field of the child are both editable (but not other fields). If you then click the title of the child entity it suddenly converts all of the text in the child to the same element as the title (H1).

If you quick edit the embedded child entity there is no issue, works just fine.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tkoleary created an issue. See original summary.

slashrsm’s picture

Priority: Major » Normal
Status: Needs work » Active
Issue tags: +Media Initiative, +D8Media
slucero’s picture

Issue summary: View changes
FileSize
394.29 KB
449.96 KB

I'm seeing this issue as well. See attached images for screenshots of the issue.

slucero’s picture

Issue summary: View changes

dshields’s picture

This is still an active issue.

Wim Leers’s picture

Title: Quickedit of parent entity "leaks" into child » Quick Edit of host entity "leaks" into embedded entities
Issue tags: +JavaScript
Related issues: +#3011228: Missing `data-quickedit-entity-id` attribute prevents in-place editing of embedded entities

Reproduced.

This actually looks like a bug in Quick Edit in Drupal core. It indeed only affects title fields of embedded entities. I vaguely recall that Quick Edit had to special case those … but obviously got something wrong in the logic! Will need to do some JS debugging to figure this out.

Also, FYI: #3011228: Missing `data-quickedit-entity-id` attribute prevents in-place editing of embedded entities's patch solves that issue, but does not help fix this.

Wim Leers’s picture

Title: Quick Edit of host entity "leaks" into embedded entities » [upstream] Quick Edit of host entity "leaks" into embedded entities
Issue tags: +BarcelonaMediaSprint

Updating the title to explicitly communicate that this is indeed a core bug.

Wim Leers’s picture

I cannot reproduce this when embedding media entities, which is the most common use case for entity_embed.

Keeping this marked as normal bug report, but removing it from #2577891: Entity Embed 8.x-1.0.0-rc1 release.

Wim Leers’s picture

I suspect I may have been testing #2940029: Add an input filter to display embedded Media entities when I wrote #8.

Quoting #2940029-38: Add an input filter to display embedded Media entities:

Next up is test coverage, as described in #27, specifically these two bullets:

  • […]
  • in-place editing and contextual links are explicitly disabled; the reason being that it's going to be a terrible UX if content authors can in-place edit embedded entities, because most of them will assume that will only affect that specific embed (to be ported to Entity Embed, and this will also affect its test coverage)

Entity Embed definitely is still susceptible to this, as this failing test shows.

The draft core patch already addressed this. Let's port that logic, but let's first prove it's broken right now.

Wim Leers’s picture

Status: Active » Needs review
Wim Leers’s picture

This is ported as close as possible from #2940029: Add an input filter to display embedded Media entities's patch. I think this will cause some test failures though because it is running for all @EntityEmbedDisplay plugins right now, rather than only the view mode-based one. I'll fix that tomorrow :)

Wim Leers’s picture

Assigned: Unassigned » Wim Leers

Assigning to me; I'll continue tomorrow.

Status: Needs review » Needs work

The last submitted patch, 11: 2614364-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Wim Leers’s picture

Status: Needs work » Needs review
FileSize
7.23 KB
5.01 KB

Reverted changes that #11 made to EntityEmbedBuilder, because like #11 predicted, it caused problems elsewhere.

Also, this took me multiple hours to figure out. @EntityEmbedDisplay plugins building on top of formatters in core and being derived and being configurable made this super complex — at least for me.

Wim Leers’s picture

Issue tags: -D8Media
FileSize
428 bytes
5.03 KB

Green again — yay :)

Confusingly, #9 passed tests. It should not have. And actually … it did not. This is DrupalCI's reporting being flaky.

At https://www.drupal.org/pift-ci-job/1329534 you can see the last daily test run against the HEAD of the branch. 88 passes. #9 is adding a new test, and yet still only 88 passes. This means the new test was not executed.

And sure enough:

00:04:51.266 Tests to be run:
00:04:51.267   - Drupal\Tests\entity_embed\Functional\ViewModeFieldFormatterTest
00:04:51.267   - Drupal\Tests\entity_embed\Functional\RecursionProtectionTest
00:04:51.267   - Drupal\Tests\entity_embed\Functional\ImageFieldFormatterTest
00:04:51.268   - Drupal\Tests\entity_embed\Functional\FileFieldFormatterTest
00:04:51.268   - Drupal\Tests\entity_embed\Functional\EntityReferenceFieldFormatterTest
00:04:51.268   - Drupal\Tests\entity_embed\Functional\EntityEmbedUpdateHookTest
00:04:51.269   - Drupal\Tests\entity_embed\Functional\EntityEmbedTwigTest
00:04:51.269   - Drupal\Tests\entity_embed\Functional\EntityEmbedHooksTest
00:04:51.270   - Drupal\Tests\entity_embed\Functional\EntityEmbedEntityBrowserTest
00:04:51.270   - Drupal\Tests\entity_embed\Functional\EntityEmbedDisplayManagerTest
00:04:51.270   - Drupal\Tests\entity_embed\Functional\EntityEmbedDialogTest
00:04:51.271   - Drupal\Tests\entity_embed\Kernel\EntityEmbedFilterTranslationTest
00:04:51.271   - Drupal\Tests\entity_embed\Kernel\EntityEmbedFilterTest
00:04:51.271   - Drupal\Tests\entity_embed\Kernel\EntityEmbedFilterOverridesTest
00:04:51.272   - Drupal\Tests\entity_embed\Kernel\EntityEmbedFilterLegacyTest
00:04:51.272 
00:04:51.272 Test run started:

Note the absence of \Drupal\Tests\entity_embed\Kernel\EntityEmbedFilterDisabledIntegrationsTest. Same in #14.

Looks like the class name doesn't match the filename, that probably caused it.

oknate’s picture

I'm not sure about this:

+    if ($this->getPluginId() !== 'entity_reference:entity_reference_entity_view') {
+      return $build;
+    }

Isn't it possible that there are other plugins that render the entity that don't have that plugin id? Should we allow other plugins to opt to what comes after the return statement here? Could we check if it inherits from the base class instead?

For the alt and title we added another attribute, $definition['supports_image_alt_and_title']), perhaps we should follow a similar approach here?

$definition['renders_entity']) or something like that.

Wim Leers’s picture

Ah, 91 tests passed — this time it worked! :)

Now let's fix the sole coding standards violation and upload a fail/pass patch.

Isn't it possible that there are other plugins that render the entity that don't have that plugin id? Should we allow other plugins to opt to what comes after the return statement here? Could we check if it inherits from the base class instead?

We want to do this whenever a view mode/EntityViewDisplay-powered representation of an entity gets rendered, because that's where contextual links and Quick Edit may appear.

That's an important difference with supports_image_alt_and_title, where for example alt may be overridden both when formatting an image Media entity's image directly and when viewing an image Media item in whichever view mode.

However … it's possible that contrib modules are subclassing the existing formatter to layer on special behaviors. Turns out for example entity_reference_override does this!

Fortunately there's a reliable way to detect whether a render array is generated by EntityViewBuilder, which is really what we're after.

The last submitted patch, 17: 2614364-17-test_only_FAIL.patch, failed testing. View results

Wim Leers’s picture

Title: [upstream] Quick Edit of host entity "leaks" into embedded entities » Quick Edit of host entity "leaks" into embedded entities: disable Quick Edit
Status: Needs review » Reviewed & tested by the community
Issue tags: -JavaScript

I think #17 is ready :)

Also: there's nothing upstream-related nor JavaScript-related here anymore, so updating title and tags.

Crediting everybody who participated in this issue 🙏

  • Wim Leers committed c171ab0 on 8.x-1.x
    Issue #2614364 by Wim Leers, slucero, tkoleary, oknate, slashrsm,...
Wim Leers’s picture

Status: Reviewed & tested by the community » Fixed

🚢

Status: Fixed » Closed (fixed)

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