Core Messages duplicated in Mercury Editor form

Created on 7 January 2025, 7 months ago

Problem/Motivation

I'm trying to send a status message using the core messenger service in Drupal 10. The message ends up being duplicated.

Its getting printed twice on the mercury editor page due to line 12 ({{ form['status_messages'] }}`) of mercury-editor-entity-form.html.twig.

Separate issue but related to the the same form (first time I have seen this) the following is printed out in the twig on development

<!-- INVALID FILE NAME SUGGESTIONS: See https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/function/hook_theme_suggestions_alter
   mercury_editor_entity_form -->

Steps to reproduce

Don't judge as the following is just the start of my development for an assigned tasked and nowhere near complete.

I added the following to a hook_form_alter().

 $messenger = \Drupal::messenger();
      $state = $form["moderation_state"]['widget'][0]['state']['#default_value'];
      $messenger->addMessage(t('This content is currently @state.', ['@state' => $state]), MessengerInterface::TYPE_WARNING);

And the screenshot is what I see on my content node using Mercury Editor.

The top is the message printed from core and the bottom from mercury-editor-entity-form.html.twig.

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States pbabin

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

Comments & Activities

  • Issue created by @pbabin
  • πŸ‡ΊπŸ‡ΈUnited States pbabin
  • πŸ‡ΊπŸ‡ΈUnited States pbabin
  • πŸ‡ΊπŸ‡ΈUnited States fizcs3 Omaha, Nebraska; USA

    I'm seeing the same duplication of status messages; on mercury_editor 2.2.4.
    In our case, we are using the contrib content_lock module, and it's message appears:

    What I'm finding is that the {{ form['status_messages'] }} (mentioned above, and below) is displaying the second smaller status message.
    templates/mercury-editor-entity-form.html.twig

    {{ attach_library('mercury_editor/node_form') }}
    {{ form['status_messages'] }}
    <header class="me-node-form__header">
      <h1 class="me-node-form__title">{{ form['#title'] }}</h1>
    </header>
    {{ form|without('status_messages', 'advanced', 'footer', 'actions', 'gin_actions', 'gin_sidebar', 'gin_sidebar_toggle') }}
    

    It's the page template that displays the larger "system" status message at the top via {{ page.highlighted }}:
    templates/page--mercury-editor.html.twig

    <mercury-dialog id="me-edit-screen" hide-close-button push resizable dock="right">
      {{ page.highlighted }}
      {{ page.content|without(local_actions_block) }}
    </mercury-dialog>
    

    So, it depends which status message style is wanted here? I presume the second one is what we want, less space used.
    If so, then the task instead would be to remove the status message that displays in the highlighted region...

Production build 0.71.5 2024