Problem/Motivation

After encrypting the proc_entity_reference_field file and AJAX refreshed the CKEditor powered field has lost UI and previously entered formatted input as a raw html.

Steps to reproduce

  1. Add and format some content in the CKEditor powered field.
  2. Upload a file and encrypt it.
  3. Observe the issue.

The module constructs an element ID like #edit-field-my-field-0-metadata to replace its html though the Drupal generated IDs can have uniqueness suffixes so this mismatch triggers detaching behaviors from the form, hence lost CKEditor UI & formatted input.

Proposed resolution

Use a custom Drupal\Core\Ajax\HtmlCommand and data-proc-metadata selector for the field to reliably select all the proc field instances for AJAX refreshing.

Remaining tasks

No.

User interface changes

No.

API changes

No.

Data model changes

No.

Issue fork proc-3636694

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

drugan created an issue. See original summary.

drugan’s picture

Status: Active » Needs review
shank115’s picture

Status: Needs review » Reviewed & tested by the community

Tested MR !3 on Drupal 11.4.8 with an article that has a CKEditor body and a proc field.

Steps:

  1. Format some text in the body.
  2. Click "Add another item" on the proc field (AJAX rebuild).
  3. Encrypt a file on the first item.

Before the MR: the CKEditor toolbar disappears and the body shows raw HTML.
After the MR: the editor and formatting stay, and the encryption date shows under the right item.

Minor: the '// Replace _ by - in field name:' comment in ProcEncryptForm::setMetadataMessage() is now stale.

RTBC from my side.

drugan’s picture

Status: Reviewed & tested by the community » Needs review

@shank115
Thanks for the review.
I removed the leftover comment in the last commit.

rodrigo panchiniak fernandes’s picture

Status: Needs review » Fixed

Merged. Thanks @drugan and shank115! This will be included in the next release.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.