Field (widget) descriptions are displayed wrong (should not be in form-item__suffix

Created on 4 June 2024, 8 months ago

Problem/Motivation

Using a field description for a physical field, the description isn't shown as expected, but in large font size.

The reason is, that the description is put into form-item__suffix but should be a sibling of that (compare with all other field types)

<span class="form-item__suffix">mm<div class="description">This is my field description</div></span>

should be (as for all other fields)

<span class="form-item__suffix">mm</span>
<div class="description">This is my field description</div>

otherwise, the description is displayed wrongly, as it differs from the expected structure by claro.

Steps to reproduce

  1. Use a physical field
  2. Give it a field description
  3. See the description in large text in Claro-based (admin) themes like Gin

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

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

Merge Requests

Comments & Activities

  • Issue created by @Anybody
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica

    This is really looking bad and exceeds the page width, so should be fixed.

  • First commit to issue fork.
  • Pipeline finished with Success
    5 months ago
    Total: 145s
    #253984
  • Pipeline finished with Failed
    5 months ago
    Total: 157s
    #253993
  • Status changed to Needs review 5 months ago
  • 🇩🇪Germany Grevil

    Fixed. please review!

    Before:

    After:

  • 🇩🇪Germany Grevil

    I accidentally removed the labels (Length, Width, Height). Fixed it again.

  • 🇩🇪Germany Grevil

    New output:

  • Pipeline finished with Success
    5 months ago
    Total: 488s
    #254657
  • 🇩🇪Germany Grevil

    Since @Anybody asked internally whether the measurement element help text is still displayed, when having only 1 unit available, here is that output:

  • 🇩🇪Germany Grevil

    And here for dimensions:

  • Status changed to RTBC 5 months ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Thank you @Grevil! This fixes the issue for us and now looks correct in general. I couldn't find any issues with the solution.

    Regarding the code comments I think the maintainers should have a look. If removing that, I think it might better happen in a follow-up.

  • Status changed to Needs work 5 months ago
  • 🇮🇱Israel jsacksick

    Haven't tested the patch myself manually, but the main thing I can see is that we're now extending FormElementBase which only exists from D10.3... So by doing this you're making the module compatible with Drupal >D10.3...

    See https://www.drupal.org/node/3436275 .

  • 🇩🇪Germany Anybody Porta Westfalica

    @jsacksick thanks! So it might make sense to just use the non *Base for now and later on replacing them in a 2.x branch when preparing the ^12 compatible version?

    Otherwise, we'd need two branches already and that would be extra work for you...

    Just to give us a direction how you'd like it! (As non-maintainers it's always good to know which direction the maintainer wants to go into, to not put work into things that will be rejected later on... that's why I ask these questions and very much like early general (green / yellow / red light) maintainer feedback)

    Thank you!

  • 🇮🇱Israel jsacksick

    thanks! So it might make sense to just use the non *Base for now and later on replacing them in a 2.x branch when preparing the ^12 compatible version?

    Yes, exactly... No point in opening a new branch just to fix this deprecation, D12 is planned for mid 2026 afaik, so there is time...

  • Status changed to Needs review 5 months ago
  • 🇩🇪Germany Grevil

    Alright! Reverted that change! Please review once again.

  • Pipeline finished with Success
    5 months ago
    Total: 159s
    #271430
  • Pipeline finished with Success
    5 months ago
    Total: 161s
    #272258
  • 🇩🇪Germany Grevil

    Dropped the "container" theme wrapper. Should be all done now! :)

  • Status changed to Needs work 5 months ago
  • 🇩🇪Germany Grevil

    Found one more thing...

  • 🇩🇪Germany Grevil

    The Number form element ("physical_number") has their own "form_element" theme wrapper set. Since this form element is rendered in Measurement ("physical_measurement"), which now also defines a "form_element" theme wrapper we have two wrappers in place, which will result in a weird looking gab between the input field and the label / help text:

    I'll see if I can fix this without simply removing the Number theme wrapper.

  • 🇩🇪Germany Anybody Porta Westfalica

    I guess structurally it might be fine to keep both, as for some physical field elements it's a combo. So if needed we might fix this visually via CSS?

    It's at least already better and more standardized than the implementation before.

  • Status changed to Needs review 5 months ago
  • 🇩🇪Germany Grevil

    Alright, unfortunately this isn't easily fixable.

    It seems we can not (easily) remove the theme wrapper of the child "physical_number" form element in "physical_dimensions" / "physical_measurement" and removing the "form_element" wrapper inside the "Number" ("physical_number") class itself would:
    A. Introduce a breaking change, as "physical_number" can't have a description nor label anymore
    B. "physical_number" won't support "#field_suffix" anymore and a lot would break.

    Taking a look at the before and after in #9 🐛 Field (widget) descriptions are displayed wrong (should not be in .form-item__suffix) Needs work I would say, that the original issue is fixed and any further work should go into a following issue (or rather 🐛 Dimensions render element / field widget styling lost when used with Claro Needs work ).

  • With the patch everything works perfectly fine in the admin forms & on frontend. The field description is rendered separately as usual.

    So RTBC from my side.

    Very hard to work around this issue without the patch if the rendered description markup is included in #suffix and of course, it looks completely broken. So it would be very nice to have this merged & released soon.

  • 🇩🇪Germany Anybody Porta Westfalica

    MR as static patch for composer for the meantime, but I agree it would be great to have this merged and released soon!

    Confirming RTBC - thanks for the wakeup call!

  • Pipeline finished with Skipped
    3 months ago
    #324044
  • 🇩🇪Germany Grevil

    Thanks!

  • Status changed to Fixed 2 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024