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

But if 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.
Root cause CSS selector seems to be
td > .form-item > .claro-autocomplete > .form-element {
width: 100%;
}
Setting to "auto" or removing it fixes the issue. As I have no idea why it is 100% I'm not sure what the intentional idea was about the 100%. Maybe there is a better solution than removing the 100% width.
Remaining tasks
Write tests
Review
User interface changes
Before:

After:

Introduced terminology
None
API changes
None
Data model changes
None
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #44 | prefix-no-padding.png | 47.27 KB | benjifisher |
| #27 | Screenshot 2024-12-31 at 11.42.23 PM.png | 216.36 KB | saurav-drupal-dev |
| #26 | MR Error Prefix-Suffix .png | 18 KB | sagarmohite0031 |
| #25 | table-cells.png | 156.04 KB | ahsannazir |
| #22 | Screenshot 2024-12-03 at 4.01.50 PM.png | 214.28 KB | saurav-drupal-dev |
Issue fork drupal-3471459
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
marc.bauComment #3
marc.bauComment #4
marc.bauComment #5
quietone commentedChanges are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.
Comment #6
marc.bauThe 100% width is also causing the issue in #3471683
Comment #9
nayana_mvr commentedI'm able to reproduce the issue in Drupal core 11.x . Steps followed:-
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.

Comment #10
smustgrave commentedHave not reviewed.
MR has build issues.
Comment #11
nayana_mvr commentedOne file was missing in the commit. I have added that and now the build issue is fixed. Kindly review.
Comment #12
smustgrave commentedSeems like a straight enough fix.
Comment #13
quietone commentedThis 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.
Comment #14
nayana_mvr commentedThere 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 andwidth: 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 togglingwidth:100%.I'm not sure if we can remove
widthcompletely here. Better to write tests.Updated IS with before and after screenshots.
Comment #15
larowlanThe 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.
Comment #16
nayana_mvr commentedThanks! @larowlan for the suggestions. I have implemented those changes except
flex-growsince form element seems to be getting adjusted correctly even withoutflex-growbecause ofwidth:100%. Below are the changes done in this commit:-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.
Comment #17
nayana_mvr commentedComment #18
marc.bauGreat. That looks visually much better than my quick fix.
Comment #19
smustgrave commentedBelieve feedback has been addressed on this one.
Comment #20
larowlanPinging FE framework managers to confirm they're ok with this.
Comment #21
bnjmnmI checked a few spots with table cells that contain

.form-itemand I saw that in taxonomy term tables the "Status" items are no longer aligned with their header.Comment #22
saurav-drupal-dev commentedHi @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.
Comment #25
ahsannazir commentedRemoving
justify-content: centerfixes the alignment of Status items.Comment #26
sagarmohite0031 commentedHello,
Getting error while applying MP.
Attaching error screenshot-
Comment #27
saurav-drupal-dev commentedIssue Fixed for me applied MR manually. RTBC+
Comment #28
smustgrave commented@saurav-drupal-dev there's already a valid set of screenshots on the issue, additional ones aren't needed. Thanks.
Comment #29
smustgrave commentedStatus regression appears to be addressed.
Comment #33
nod_Committed bffe969 and pushed to 11.x. Thanks!
Comment #35
hhvardan commentedThe fix from this issue (commit 937a5478) introducing display: flex on the .form-item seems to be causing some layout regressions elsewhere—specifically with multi-value Link fields.
The details are here #3532656: Multi-Link Fields styling applying flex class.
Comment #36
nod_Too many side effects, reverting
Comment #37
acbramley commentedFor some reason the revert commit didn't link up here.
https://git.drupalcode.org/project/drupal/-/commit/9ce9ba1c8d0c4d13dd0a3...
Comment #38
benjifisherI am giving credit on this issue to people who contributed to #3519949: [regression] Claro CSS selector 'td > .form-item' should be more specific: it targets many fields and the Permissions form. I may be too stingy: I did not give credit to the authors of Comments 2, 4, 5, 6, 10, 12 , 13, 16, 18, nor myself.
For testing purposes, see Comment #34 (@marcoliver) from that issue:
(I took the liberty of making "quick and dirty module" a link to the zip file.)
Comment #39
robloachThanks for the revert. If we do take something like this on, we should likely be specific about which `td` we're targeting. Is there a parent class that we could hit?
Comment #42
marcoliverFor what its worth, I opened a branch/an MR with an attempt at what I proposed a while back in the regression issue: to conditionally wrap prefix, field, and suffix in another element and apply the styles from the original fix to that wrapper instead.
Could this perhaps be a workable approach?
Comment #43
smustgrave commentedAnyway to do this without the twig change? Only ask because then we need a CR as other themes will have
Comment #44
benjifisher@smustgrave:
Did your comment get truncated?
The markup in 11.x looks something like this:
The change that had to be reverted (which you marked RTBC in Comment #29) made any
td > .form-itema flex container. That caused lots of problems, as discussed in #3519949: [regression] Claro CSS selector 'td > .form-item' should be more specific: it targets many fields and the Permissions form. Even if we add a class to the wrapper div and target that class, we have the problem that the wrapper contains the description after the prefix, input, and suffix. That leads to this behavior (screenshot from the description of #3519949):@marcoliver:
I think this is the right direction, but there are some problems. Just as @ifrik pointed out in Comment #27 on #3519949, it does not work well on narrow screens. Another problem I noticed is that there does not seem to be any padding nor margin between the prefix and the input field. This gets even worse (at least on Firefox/Linux) when the input has focus:
I am setting the status to NW.