Problem/Motivation

When using the new experimental Claro admin theme, the paragraphs action buttons in the table header of field multiple value forms are overridden due to the implementation Claro uses to add a CSS class to the field label there.

This is what Claro does in claro_preprocess_field_multiple_value_form():

$variables['table']['#header'][0]['data'] = [
  '#type' => 'html_tag',
  '#tag' => 'h4',
  '#value' => $variables['element']['#title'],
  '#attributes' => $header_attributes,
];

Unfortunately, the Paragraphs module also changes the table structure to inject its buttons like this in paragraphs_preprocess_field_multiple_value_form():

if (!empty($variables['table']['#rows'][0]['data'][1]['data']['#paragraphs_header'])) {
  $variables['table']['#header'][0]['data'] = [
    'title' => $variables['table']['#header'][0]['data'],
    'button' => $variables['table']['#rows'][0]['data'][1]['data'],
  ];
  unset($variables['table']['#rows'][0]);
}

This has never been a problem, because Paragraphs assumed the structure created by template_preprocess_field_multiple_value_form() (can be found in core/includes/theme.inc) and acted on top of it. But Claro as a new player in the chain acts on top of that now - but also assumes the unchanged structure of template_preprocess_field_multiple_value_form() without any sub-items in that particular table header cell.

Proposed resolution

  • Discuss where to fix this issue. There are several locations that might need some changes for this:
    • template_preprocess_field_multiple_value_form() which might add the label with a dedicated key as a sub-item of the data property of the cell (so others can easily work on it)
    • claro_preprocess_field_multiple_value_form() which should be take in mind, that other contribs may change the structure of the table header cell's variable structure
    • paragraphs_preprocess_field_multiple_value_form() which may be tried to be moved to the end of the chain to work with the variable structure as usual... or a completely different approach may also be used?!

Remaining tasks

TBD

User interface changes

  • Paragraph actions buttons should be available with Claro again

API changes

n/a

Data model changes

n/a

Release notes snippet

n/a

Issue fork paragraphs-3099024

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

hctom created an issue. See original summary.

hctom’s picture

hctom’s picture

I created a patch over at #3099026: Claro's preprocessing of field multiple value form's table header cell removes potential changes by others that should work as a basis. I'd appreciate your feedback.

jwilson3’s picture

I've tested the patch on the core issue. works well, but we need a patch here to deal with some layout issues inside the header.

See comment #10 on #3099026-10: Claro's preprocessing of field multiple value form's table header cell removes potential changes by others.

lauriii’s picture

Some of the changes Paragraphs does in paragraphs_preprocess_field_multiple_value_form are pretty invasive. It might make sense to force the paragraphs preprocess function to run last with something like this:

/**
 * Implements hook_theme_registry_alter().
 */
function paragraphs_theme_registry_alter(&$theme_registry) {
  $key = array_search('paragraphs_preprocess_field_multiple_value_form', $theme_registry['field_multiple_value_form']['preprocess functions']);
  unset($theme_registry['field_multiple_value_form']['preprocess functions'][$key]);
  $theme_registry['field_multiple_value_form']['preprocess functions'][] = 'paragraphs_preprocess_field_multiple_value_form';
}

jstoller made their first commit to this issue’s fork.

jstoller’s picture

Status: Active » Needs review

I turned lauriii's code from #6 into a merge request. It fixes the problem for me.

pcate’s picture

Status: Needs review » Reviewed & tested by the community

Ran into this issue with a client using the Gin theme. The MR fixed the issue and now all the edit/collapse and drag and drop header buttons are showing.

Berdir made their first commit to this issue’s fork.

  • Berdir committed f6781607 on 8.x-1.x authored by jstoller
    Issue #3099024 by jstoller: Paragraphs actions button are removed when...
berdir’s picture

Status: Reviewed & tested by the community » Fixed

Not sure I fully understand what this is fixing, but I doesn't seem to hurt and happy to trust @laurii on this. The core issue is now also fixed, so closing this.

Status: Fixed » Closed (fixed)

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