Problem/Motivation

Editing alignment doesn't "take" until source button pushed.

https://www.drupal.org/files/issues/2019-06-26/alignment%20issue%20-%207...

Here's the embed code:

<drupal-entity data-embed-button="media" data-entity-embed-display="entity_reference:media_thumbnail" data-entity-embed-display-settings="{&quot;image_style&quot;:&quot;thumbnail&quot;,&quot;image_link&quot;:&quot;&quot;}" data-entity-type="media" data-entity-uuid="dc89fa65-1f64-45ad-89d6-9775683ac357" data-langcode="en"></drupal-entity>

If you search for the xpath '//drupal-entity[@data-align]' it doesn't appear until you click the source button twice to refresh the contents of the CKEditor.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

oknate created an issue. See original summary.

oknate’s picture

Issue summary: View changes
oknate’s picture

It seems like it's ignoring the data-align attribute because it's initially missing.

Wim Leers’s picture

Title: Alignment doesn't display until source button pushed » [regression] Follow-up for #3037316: alignment doesn't display until source button pushed
Component: Code » CKEditor integration
Status: Active » Needs review
Issue tags: +JavaScript
Related issues: +#3037316: Show an outline around the <drupal-entity> element within CKEditor
FileSize
647 bytes

It seems like it's ignoring the data-align attribute because it's initially missing.

Bingo.

But! The server-side preview is updated.

It's because of #3037316: Show an outline around the <drupal-entity> element within CKEditor that this does not work! It's the <drupal-entity> tag whose data-align determines the CSS that applies, and it not being updated also results in the problem you demonstrated in the screencast. Try starting with data-align=center, then it seems that using the dialog to change it to right works, but the wrong CSS applies, because in the DOM it's still drupal-entity[data-align=center].

This is a consequence of keeping <drupal-entity> around rather than stripping it entirely. CKEditor's Widget API doesn't let us do that unfortunately.

oknate’s picture

Status: Needs review » Reviewed & tested by the community

Manually tested, and confirmed the fix. We could add test coverage, but I don't have time this morning. Perhaps in a follow-up issue.

  • Wim Leers committed 2165b4d on 8.x-1.x
    Issue #3064287 by Wim Leers, oknate: [regression] Follow-up for #3037316...
Wim Leers’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +Media Initiative

I don't think test coverage is necessary in this case; that'd amount to visual regression testing. We could test the updating of those attributes, yes, but that's testing a side effect, not the actual problem.

So +1 to landing this as-is.

🚢

Status: Fixed » Closed (fixed)

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