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 structureparagraphs_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
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | Screen Shot 2020-03-25 at 6.16.09 PM.png | 49.38 KB | jwilson3 |
| #5 | Screen Shot 2020-03-25 at 6.16.16 PM.png | 26.82 KB | jwilson3 |
Issue fork paragraphs-3099024
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
Comment #2
hctomI created a related Claro issue for this: #3099026: Claro's preprocessing of field multiple value form's table header cell removes potential changes by others
Comment #3
hctomComment #4
hctomI 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.
Comment #5
jwilson3I'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.
Comment #6
lauriiiSome of the changes Paragraphs does in
paragraphs_preprocess_field_multiple_value_formare pretty invasive. It might make sense to force the paragraphs preprocess function to run last with something like this:Comment #9
jstollerI turned lauriii's code from #6 into a merge request. It fixes the problem for me.
Comment #10
pcate commentedRan 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.
Comment #13
berdirNot 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.