Node gets unpublished on every content save

Created on 7 December 2023, 7 months ago
Updated 19 April 2024, 2 months ago

Version

"drupal/mercury_editor": "^2.1@alpha"

Problem

Unless I'm missing something, there is no where in the admin to publish the node. If I edit a published node and I click save it automatically unpublishes the content. I'm attaching screenshots of the first edit, and the result after clicking save.

πŸ’¬ Support request
Status

Active

Version

2.1

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States jsheffers

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

Comments & Activities

  • Issue created by @jsheffers
  • πŸ‡ΊπŸ‡ΈUnited States jsheffers

    Might be compatibility issue with the Gin theme:

    I don't see these options available with the Mercury editor. Has anyone done this?

  • Yes, I found this too. When switching the admin theme back to Claro, there's a "Publish" tickbox at the bopttom of the screen. But I can't see how it's possible to publish with Gin

  • πŸ‡¬πŸ‡·Greece dotoree

    The problem is that status field belongs to gin_actions group and form renders without this group, so we need to move status out of this group.

    Not sure in which level should be patched, but you can override the template through a custom module to fix the problem:

    a) create a new module 'my_module' and make sure that executes after mercury_editor

    b) create a template in my_module/templates named 'mercury-editor-entity-form--custom.html.twig' with contents:

    {#
    /**
     * @file
     * Theme override for a node edit form.
     *
     * Single-column template for the node edit form.
     *
     * @see claro_form_node_form_alter()
     */
    #}
    {{ 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>
    {# Remove status group when in gin_actions #}
    {% if form.status['#group'] == 'gin_actions' %}
      {% set status = form.status %}
      {% set status = status|merge({ '#group' : null }) %}
      {% set form = form|merge({ status: status }) %}
    {% endif %}
    {{ form|without('status_messages', 'advanced', 'footer', 'actions', 'gin_actions', 'gin_sidebar', 'gin_sidebar_toggle') }}
    {{ form.advanced }}
    {{ form.actions }}
    {{ form.footer }}
    

    c) in my_module.module:

    /**
     * Implements hook_theme_suggestions_alter().
     */
    function my_module_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
      switch ($hook) {
        case 'node_edit_form':
          if (in_array('mercury_editor_entity_form', $suggestions)) {
            $suggestions[] = 'mercury_editor_entity_form__custom';
          }
          break;
      }
    }
    
    /**
     * Implements hook_theme().
     */
    function my_module_theme($existing, $type, $theme, $path) {
      return [
        'mercury_editor_entity_form__custom' => [
          'base hook' => 'mercury_editor_entity_form',
        ],
      ];
    }
    
  • πŸ‡ΊπŸ‡ΈUnited States boinkster

    I can confirm that this a Gin problem. Tried the fix in #4 and the twig isn't loading. I haven't had time to track down what changed and where it's failing. If this isn't too much of a moving target, maybe it should be an extra module in Mercury or contrib.

  • πŸ‡¬πŸ‡·Greece dotoree

    @boinkster: One potential caveat is that your custom module (aka 'my_module' in example) should fire after mercury editor. This can be done with some something like Modules Weight β†’ module or with custom code.

Production build 0.69.0 2024