Prefix/Suffix not inline with autocomplete field

Created on 1 September 2024, 4 months ago

Problem/Motivation

The prefix and suffix of fields works well if textfields are shown:

But ff you have an entity reference with autocomplete in a multifield it is no longer inline. See the screenshot, please.

Verfied with Claro in D10.3.2.

Steps to reproduce

1. Add an entity reference with limit of 2 fields.
2. Add a suffix and prefix.

Proposed resolution

Make it inline like text fields.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component
Claroย  โ†’

Last updated 2 days ago

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany marc.bau

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

Merge Requests

Comments & Activities

  • Issue created by @marc.bau
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany marc.bau
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany marc.bau
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany marc.bau
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany marc.bau

    The 100% width is also causing the issue in #3471683

  • First commit to issue fork.
  • Pipeline finished with Failed
    4 months ago
    Total: 124s
    #274315
  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nayana_mvr

    I'm able to reproduce the issue in Drupal core 11.x . Steps followed:-

    1. Created a new text field and entity reference field with limit 2 in the content type 'Article'
    2. Created a custom module
    3. Added 'field_prefix' and 'field_suffix' for both the newly created fields.
    4. For text field, prefix and suffix are coming as inline but for entity reference itโ€™s not.

    Attached screenshots for reference

    I tried the suggested solution i.e., changing width: auto; for the entity reference input element and it fixes the issue. Also, created an MR for the same.

    Noticed that entity reference field without limit doesnโ€™t have 100% width. So making the above changes, both type of entity reference fields will have same width. I'm not sure if that is an issue here.

  • Status changed to Needs work 4 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Have not reviewed.

    MR has build issues.

  • Pipeline finished with Success
    3 months ago
    Total: 582s
    #278078
  • Status changed to Needs review 3 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nayana_mvr

    One file was missing in the commit. I have added that and now the build issue is fixed. Kindly review.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Seems like a straight enough fix.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    This is changing the UI so tagging. That got me looking for screenshots. The latest before and after screenshots should be available from the issue summary, in the "User interface changes" to help reviewers. Fortunately, there are only a few comments here so I found that in #9. They look correct but why is there a screenshot of 'tags', https://www.drupal.org/files/issues/2024-09-05/3471459-entity-reference-... โ†’ ?

    The proposed resolution questions why the value is "100%" and then says that removing it or changing it to 'auto' works. The implemented solution uses 'auto' but there is no discussion of why that option was chosen, nor is there any investigation in to why it is 100%.

    This seems like a good thing to have a test for, to prevent regressions.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nayana_mvr

    There is one observation :- the issue mentioned in the ticket occurs when Autocomplete widget is used in the form display whether the field is limited or unlimited. If Autocomplete (Tags style) widget is used, then this issue doesnโ€™t occur.
    The screenshot of 'tags' was added just to show how an entity reference field with unlimited value + Autocomplete (Tags style) widget looks like in the form. As you can see in the screenshot, the width of that field is not set to 100%. When Autocomplete widget is used, the field appear as a table and width: 100% was set to the input elements and I think it was done so that it will cover the entire row of the table. Attaching a screen recording of entity reference field without prefix/suffix and toggling width:100%.

    I'm not sure if we can remove width completely here. Better to write tests.

    Updated IS with before and after screenshots.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    The comment in #14 sounds like we have an unintended regression here.
    Would it be better to set the parent element that contains the two prefix spans and the form element to display flex, setting flex-grow on the form element. That way it would be 100% if there's no prefix/suffix but otherwise they'd all be on the same line.

  • Pipeline finished with Success
    about 2 months ago
    Total: 626s
    #319102
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nayana_mvr

    Thanks! @larowlan for the suggestions. I have implemented those changes except flex-grow since form element seems to be getting adjusted correctly even without flex-grow because of width:100%. Below are the changes done in this commit:-

    1. Added display: flex to parent element that contains the two prefix/ suffix spans and the form element
    2. Reverted width: 100% of form element.
    3. Added spacing for prefix and suffix referring to the style used for suffix in form.css for screen width above 601px. As I'm not sure why that breakpoint was used in form.css, I added them without breakpoints in table.css

    After the above changes this is how the fields looks like and I think it's is much better than previous implementation:

    Updating IS screenshots as well.
    Please review.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany marc.bau

    Great. That looks visually much better than my quick fix.

  • Status changed to RTBC about 1 month ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Believe feedback has been addressed on this one.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    Pinging FE framework managers to confirm they're ok with this.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States bnjmnm Ann Arbor, MI

    I checked a few spots with table cells that contain .form-item and I saw that in taxonomy term tables the "Status" items are no longer aligned with their header.

  • Hi @bnjmnm

    the issue you mentioned i am unable to reproduce let me know if i am missing something.

    step i followed --

    1.go to taxonomy
    2.click on any list term
    3.add 3 terms used one of them to nest inside one term.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ahsannazir

    ahsannazir โ†’ changed the visibility of the branch 3471459-prefixsuffix-not-inline to hidden.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ahsannazir

    ahsannazir โ†’ changed the visibility of the branch 3471459-prefixsuffix-not-inline to active.

  • Pipeline finished with Success
    13 days ago
    Total: 458s
    #362973
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ahsannazir

    Removing justify-content: center fixes the alignment of Status items.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sagarmohite0031

    Hello,
    Getting error while applying MP.
    Attaching error screenshot-

Production build 0.71.5 2024