Insert new messages in the conversation doesn't respect the field structure

Created on 17 June 2019, about 5 years ago
Updated 19 January 2024, 5 months ago

I just noticed that the HTML structure is not consistent when inserting new messages in the conversation (Loading old ones or sending new ones). The ajax callback returns only the messages without the wrapper class that is added by the preprocess.

/**
 * Implements hook_preprocess_field().
 *
 * Adds a custom class to the field that can be targeted, as the default classes
 * may be altered in themes/templates, and therefore should not be depended
 * upon.
 */
function private_message_preprocess_field__private_message_thread__private_messages(&$vars) {
  foreach (array_keys($vars['items']) as $index) {
    $vars['items'][$index]['attributes']->setAttribute('class', 'private-message-wrapper');
  }
}

Code print when loading the page:

<div class="private-message-wrapper field__item">
<div id="private-message-62">
 Content
</div>
</div>

Code inserted when inserting by ajax:

<div id="private-message-62">
 Content
</div>

We should returns the same HTML structure when loading new messages by ajax. I did a quick patch to keep at least that wrapper (The JS rely on it but it is probably not necessary and easily removable).

πŸ› Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada phjou Vancouver/Paris πŸ‡¨πŸ‡¦ πŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024