Broken dropbutton in Groups field when used with Claro

Created on 18 November 2020, over 3 years ago
Updated 18 June 2023, about 1 year ago

Problem/Motivation

When editing content that has been added to a group earlier, the Groups field that lists all the groups the content belongs in has a broken dropbutton if the Claro admin theme is enabled.

<!--break-->

Steps to reproduce

1. Enable Claro admin theme.
2. Create new content.
3. Add the content to a group or groups.
4. Go back to edit the created content.
5. The dropbutton for editing/deleting a group in the Groups field is broken.

Proposed resolution

The dropbuttons are missing classes (dropbutton--multiple and dropbutton__item) that make the dropbutton get the appropriate styling in Claro. Adding the classes would allow the dropbutton to function.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

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.

  • πŸ‡ΊπŸ‡ΈUnited States dww

    Hi folks! Sorry I've been away from this queue / module for a while.

    I'm not thrilled about putting Claro-specific classes into our markup. Frankly, I think I'd rather do #3159224: Remove entitygroupfield-dropbutton-wrapper.html.twig entirely β†’ than this. πŸ˜… But I need to investigate a bit more, and now that Claro is the default core admin theme, maybe we need to do this (or something like it).

    Anyway, I hope to do more testing / investigation on all this in the near future...

    Thanks,
    -Derek

  • πŸ‡ΊπŸ‡ΈUnited States dww

    p.s. Now that I re-read the linked issue, I see these are actually related but different problems. We can (and probably should) do both.

  • Status changed to RTBC over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jstoller

    The patch in #6 works as advertised.

  • Status changed to Fixed about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States dww

    Thanks, folks!

    Reviewing #6:

    1. +++ b/css/entitygroupfield.admin.css
      @@ -49,3 +49,7 @@
      +.field--widget-entitygroupfield-select-widget .dropbutton-action .dropbutton__items {
      +  bottom: auto;
      +  top: 100%;
      +}
      

      Not clear why we need this or care. Seems a bit opinionated for the default module styles.

    2. +++ b/src/Plugin/Field/FieldWidget/EntityGroupFieldWidgetBase.php
      @@ -451,7 +451,7 @@ abstract class EntityGroupFieldWidgetBase extends WidgetBase implements Containe
                 ];
      
      @@ -467,9 +467,27 @@ abstract class EntityGroupFieldWidgetBase extends WidgetBase implements Containe
      +              $weights = [];
      +
      +              foreach ($links as $key => $link_item) {
      +                $weights[] = $link_item['#weight'];
      +              }
      +
      +              sort($weights);
      +
      +              foreach ($links as $key => $link_item) {
      +                if ($link_item['#weight'] === $weights[1]) {
      +                  $element['top']['links'][$key]['#prefix'] = '<li class="dropbutton__item dropbutton-action secondary-action"><ul class="dropbutton__items">' . $link_item['#prefix'];
      +                }
      +
      +                if ($link_item['#weight'] === end($weights)) {
      +                  $element['top']['links'][$key]['#suffix'] = '</li></ul></li>';
      +                }
      +              }
      +
      

      I'm not understanding why we want or need any of this complication. If this is actually necessary, please open a follow-up issue for it, and clearly explain (with code comments) why all this is needed.

    So I manually tested with just patch #2 (which makes more sense to me), was able to reproduce the brokenness, and #2 seemed to be sufficient to solve it. So that's what I committed and pushed. Now fixed in both 2.0.x and 1.0.x branches, and will be out in the next round of releases.

    @tanner.svg: Again, if #6 is necessary, please open a follow-up issue explaining the additional changes.

    Thanks again!
    -Derek

  • πŸ‡ΊπŸ‡ΈUnited States dww
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024