Claro's preprocessing of field multiple value form's table header cell removes potential changes by others

Created on 5 December 2019, almost 5 years ago
Updated 9 March 2023, over 1 year ago

Problem/Motivation

Currently claro_preprocess_field_multiple_value_form() assumes the table header structure created by template_preprocess_field_multiple_value_form(). But other extensions may change the structure of it (e.g. by adding sub-items in that particular cell). , The Paragraphs module e.g. does this for its action buttons in the table header. This has been no problem yet, because its preprocess hook was last in line, due to the fact, that the other core themes did not implement one on their own.

With Claro as the new admin theme though, this acts on top of the changes the Paragraphs module makes and reverts it back to the "default" structure for adding its custom CSS class on the field label.

Proposed resolution

  • Fix the issue in the following places:
    • template_preprocess_field_multiple_value_form(). Convert the title to a html_tag #type
    • claro_preprocess_field_multiple_value_form()
    • Make appropriate changes to Claro's CSS to ensure consistency and BC

Remaining tasks

Review

User interface changes

n/a

API changes

  • A potentially new variable structure for the table header cell, if a solution is chosen that changes the structure on core level

Data model changes

n/a

Release notes snippet

n/a

🐛 Bug report
Status

Fixed

Version

10.1

Component
Claro 

Last updated about 22 hours ago

Created by

🇩🇪Germany hctom

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.

  • 🇨🇭Switzerland tcrawford

    Patch #42 works great for me, also (tested 9.4.x). Thank you very much.

  • Status changed to RTBC over 1 year ago
  • 🇨🇭Switzerland tcrawford

    Moving to RTBC due to the positive feedback.

  • Status changed to Needs work over 1 year ago
  • 🇫🇮Finland lauriii Finland
    1. +++ b/core/themes/claro/claro.theme
      @@ -908,27 +908,13 @@ function claro_preprocess_field_multiple_value_form(&$variables) {
      +    if (isset($variables['table']['#header'][0]['data']['#attributes']) && $variables['table']['#header'][0]['data']['#attributes'] instanceof Attribute) {
      

      We could technically add support for array type of attributes too if that increases the chances of this working

    2. +++ b/core/themes/claro/css/components/form.pcss.css
      @@ -37,9 +37,12 @@ tr .form-item,
      +.field-multiple-table .field-label h4.label {
      

      Can we add comment explaining that this is to try to keep the styles working even when there are modules overriding the markup

    3. A small CR that warns about the render array changes would probably be useful since we know that there are some themes that would be impacted by this.
  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States mherchel Gainesville, FL, US

    Patch updated per #47. Creating CR shortly

  • Status changed to Needs work over 1 year ago
  • The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • 🇺🇸United States mherchel Gainesville, FL, US

    CR created at https://www.drupal.org/node/3344342 . Please double check this, I'm not entirely positive that what I wrote is 100% correct.

  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States mherchel Gainesville, FL, US
  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    Could the Issue summary be updated some? The proposed solution mentions there needs to be discussion. If a decision has already been made can it be documented there please.

    Thanks!

  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States mherchel Gainesville, FL, US

    Agree. Adding the "Needs issue summary update" tag.

    Note that since the patch has been created and still needs review, I'm setting this back to "Needs Review". Please see the documentation at https://www.drupal.org/docs/develop/issues/fields-and-other-parts-of-an-...

    Needs work is only for:

    There is a patch attached to the issue, but the patch needs additional work before it should be reviewed. The author of the patch may indicate that it is incomplete, or the patch has gone through the reviewing process and has received feedback about areas where it needs improvement.

  • 🇺🇸United States smustgrave

    Will leave in review but if the proposed solution isn't clear any reviewer can't review the patch to see if the approach being proposed is being followed.

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    Since it's been about a week moving back to NW as the issue summary does need to be updated.

    Don't want it to rot away in the review queue.

  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States mherchel Gainesville, FL, US
  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States smustgrave

    Actually turned into a great improvement for paragraphs

    Tested by installing paragraphs and making a dummy bundle with just a simple boolean field

    Without the patch. I can't drag and drop the header

    With the patch I can!

  • Status changed to Needs work over 1 year ago
  • 🇫🇮Finland lauriii Finland
    +++ b/core/themes/claro/claro.theme
    @@ -993,27 +993,13 @@ function claro_preprocess_field_multiple_value_form(&$variables) {
    +    if (isset($variables['table']['#header'][0]['data']['#attributes']) && $variables['table']['#header'][0]['data']['#attributes']) {
    

    Isn't the isset check here sufficient?

    What I was thinking of doing here originally was something like:

    // Convert #attributes to \Drupal\Core\Template\Attribute object to allow
    // using its utilities for modifying the attributes.
    if (!($variables['table']['#header'][0]['data']['#attributes'] instanceof Attribute)) {
      $variables['table']['#header'][0]['data']['#attributes'] = new Attribute($variables['table']['#header'][0]['data']['#attributes']);
    }
    

    However, I'm not certain we need to because it looks like we have other instances where we are already assuming that #attributes are instances of \Drupal\Core\Template\Attribute. Because of this, it's probably fine to just remove the second second condition from here.

  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States mherchel Gainesville, FL, US

    Removed the second condition per #58. Patch interdiff attached. Thanks!

  • 🇺🇸United States mherchel Gainesville, FL, US

    Attached is the same patch as above but for 9.5.x.

    IMO this bug is a major usability issue when paired with the popular Paragraphs module (which is why I'm working on this), and should be ported to 9.5.x.

  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States smustgrave

    Get the same results still using #59 so marking it again.

    And agree with the comment made in #60 that this makes paragraphs better as it shows a feature that I actually didn't know existed.

    • lauriii committed 90897afe on 10.1.x
      Issue #3099026 by mherchel, lauriii, bartlangelaan, timohuisman,...
  • Status changed to Fixed over 1 year ago
  • 🇫🇮Finland lauriii Finland

    We are allowed to change the render arrays in minor releases based on https://www.drupal.org/about/core/policies/core-change-policies/frontend... so we don't have to implement a BC layer for this. However, we cannot backport this to 9.5.x because of the potential BC concerns.

    Committed 90897af and pushed to 10.1.x. Thanks!

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

Production build 0.71.5 2024