Prefix is shown before description

Created on 8 July 2024, 2 months ago
Updated 4 September 2024, 4 days ago

Problem/Motivation

When creating a number field and filling in a prefix and description where the 'Description display' is set to 'Before', the prefix will be shown before the description instead of the field.

This results in unwanted behaviour when, for example, you've set the prefix to a currency (such as € or $) and you want to display a description above the field. It will first show the currency symbol follow by the description and the input field. Instead you want to show the description first and the currency symbol right before the input field as it makes more sense.

Steps to reproduce

  1. Create a Webform with the Webform module.
  2. Create a 'Number' element.
  3. Fill in the description.
  4. Fill in the prefix.
  5. Set 'Description display' to 'Before'.
  6. Save the element and view the form.

Proposed resolution

Show prefix in front of field instead of in front of the description when 'Description display' is set to 'Before'.

This can be done by swapping lines 71-73 with 74-78 in the following file:
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/syste...

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Form 

Last updated 1 minute ago

Created by

🇳🇱Netherlands rroose

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs frontend framework manager review

    Used to alert the fron-tend framework manager core committer(s) that a front-end focused issue significantly impacts (or has the potential to impact) multiple subsystems or represents a significant change or addition in architecture or public APIs, and their signoff is needed (see the governance policy for more information). If an issue significantly impacts only one subsystem, use Needs subsystem maintainer review instead, and make sure the issue component is set to the correct subsystem.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @rroose
  • Assigned to Sourav_Paul
  • Pipeline finished with Success
    2 months ago
    Total: 505s
    #218708
  • Issue was unassigned.
  • Status changed to Needs review 2 months ago
  • 🇮🇳India Sourav_Paul Kolkata

    Issue Fixed:

    SS:

  • 🇮🇳India Kanchan Bhogade

    I've Tested MR 8695 on Drupal 10.3.x-dev
    MR is applied Successfully...

    Testing steps:

    1. Create a Webform with the Webform module.
    2. Create a 'Number' element.
    3. Fill in the description.
    4. Fill in the prefix.
    5. Set 'Description display' to 'Before'.
    6. Save the element and view the form.

    The Prefix is shown before the Number field instead of before the description.

    Attaching SS for reference
    RTBC+1

    Keeping "Needs review" for Code verification

  • Status changed to Needs work 2 months ago
  • 🇺🇸United States smustgrave

    MR should be against 11.x branch.

    Also probably will need test coverage and definitely a change record.

    Recommend steps are updated using just core without a contrib to make sure the bug isn't from contrib.

  • Assigned to Sourav_Paul
  • Pipeline finished with Success
    about 2 months ago
    Total: 467s
    #220766
  • Pipeline finished with Success
    about 2 months ago
    Total: 492s
    #220768
  • Issue was unassigned.
  • Pipeline finished with Success
    about 2 months ago
    Total: 546s
    #220795
  • 🇮🇳India Akhil Babu Chengannur
    • web/core/profiles/demo_umami/themes/umami/templates/classy/form/form-element.html.twig
    • web/core/themes/stable9/templates/form/form-element.html.twig
    • web/core/themes/starterkit_theme/templates/form/form-element.html.twig

    All these core templates follow the same structure for prefix

      {% if prefix is not empty %}
        <span class="field-prefix">{{ prefix }}</span>
      {% endif %}
      {% if description_display == 'before' and description.content %}
        <div{{ description.attributes }}>
          {{ description.content }}
        </div>
      {% endif %}
    

    Shouldn't we update all of them. Or is it something that should be handled by the 'webform' module itself?

  • 🇳🇱Netherlands rroose

    I think we should. I see no valid reason or argument to put the prefix before the description, so it seems like a mistake or bug. The prefix is mostly used to indicate what value the user needs to enter, such as a currency.

  • Status changed to Needs review 6 days ago
  • Status changed to Needs work 6 days ago
  • 🇺🇸United States smustgrave

    Was previously tagged for tests.

    And if a template needs changed then all of them would have to be updated with a change record.

  • Status changed to Needs review 5 days ago
  • Pipeline finished with Success
    5 days ago
    Total: 524s
    #272493
  • Status changed to Needs work 5 days ago
  • 🇺🇸United States smustgrave

    Still tagged for tests.

  • 🇺🇸United States smustgrave

    Also has anyone gone through the git history for when this was added to see if done on purpose?

  • 🇮🇳India Sourav_Paul Kolkata

    From a non-developer perspective, it's a bug as it feels no purpose to put the prefix before the description but, if we put the prefix below the description, it looks quite meaningful as the prefix is mostly used to indicate what value the user needs to enter.

    I do appreciate with #13

Production build 0.71.5 2024