Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The autocomplete element does not align in views exposed forms:
Steps to reproduce
- Install Standard profile
- Expose 'field_tags' on /admin/content
Proposed resolution
Align the filters by removing the additional margin from the autocomplete element.
Remaining tasks
- Write a patch
- Review
- Commit
User interface changes
Autocomplete input in views exposed filters aligns with select and text inputs.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#55 | firefox1.png | 28.36 KB | ckrina |
#48 | issue-view.png | 40.03 KB | djsagar |
#48 | After-patch.png | 54.34 KB | djsagar |
#46 | 3116377-after.png | 23.84 KB | Abhijith S |
#46 | 3116377-before.png | 24.56 KB | Abhijith S |
Issue fork drupal-3116377
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
idebr CreditAttribution: idebr at iO commentedAttached patch removes the margin from the autocomplete element, so the exposed input elements align horizontally.
Screenshot after:
Comment #3
KondratievaS CreditAttribution: KondratievaS at Skilld commentedTested patch from #2 for in Chrome, FF, Safari, IE and result is OK
Comment #4
KondratievaS CreditAttribution: KondratievaS at Skilld commentedComment #5
jungleCoding standards check must pass, see https://www.drupal.org/pift-ci-job/1614192
Comment #6
idebr CreditAttribution: idebr at iO commentedThe coding standards messages are unrelated to this patch. Fixing them here would be scope creep.
Comment #8
swatichouhan012 CreditAttribution: swatichouhan012 at Valuebound for Valuebound commentedRerolled patch #2 for test pass
Comment #9
KondratievaS CreditAttribution: KondratievaS at Skilld commentedI can reproduce issue if field has Help text
Comment #10
KondratievaS CreditAttribution: KondratievaS at Skilld commentedComment #11
mmd CreditAttribution: mmd at AnyforSoft commentedAlso, need to resolve case when the form element has a long description.
Comment #12
sauravk CreditAttribution: sauravk as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedComment #13
sauravk CreditAttribution: sauravk as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedComment #14
KondratievaS CreditAttribution: KondratievaS at Skilld commentedTested patch from #13 in Chrome, FF, IE, Safari for desktop and mobile and result is OK
Comment #15
KondratievaS CreditAttribution: KondratievaS at Skilld commentedComment #17
xjmComment #18
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company commentedpatch at #13 worked fine for me. RTBC +1
Comment #19
ckrinaAdding a
max-width
on bigger screens is really useful, but on the smaller ones doesn't makes sense the fields don't get the full width having enough space. So I'd suggest to add to wrap themax-width
value into a media query.Comment #20
lauriiiWe can certainly add the rule to media query but we don't set the inputs as width 100% at the moment.
I missed that we have that for text inputs but not selects. We should add the rule in a media query like @ckrina suggested.
Comment #21
komalk CreditAttribution: komalk at Srijan | A Material+ Company for Drupal India Association commentedWrap the max-width value into a media query.
Review the patch attached screen shot for the reference.
Comment #22
IndrajithKB CreditAttribution: IndrajithKB at Srijan | A Material+ Company for Drupal India Association commentedHi @komalkolekar please re-roll the patch. Fix lint error.
Comment #23
IndrajithKB CreditAttribution: IndrajithKB at Srijan | A Material+ Company for Drupal India Association commentedComment #24
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedWorking on this.
Comment #25
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedHere I have addressed comment #22.
Comment #26
priyanka.sahni CreditAttribution: priyanka.sahni at Srijan | A Material+ Company for Drupal India Association commentedComment #27
priyanka.sahni CreditAttribution: priyanka.sahni at Srijan | A Material+ Company for Drupal India Association commentedVerified and tested by applying the patch #25.It looks good to me.Can be moved to RTBC.
Steps to test-
1. Go to admin site.
2. Go to admin/appearance.
3. Enable the Claro theme.
4. Go to admin/structure/views/view/content.
5. Make changes in View for content type.
6. Verify the content type page.
Before Patch -
After Patch Desktop -
After Patch Mobile -
Comment #28
priyanka.sahni CreditAttribution: priyanka.sahni at Srijan | A Material+ Company for Drupal India Association commentedComment #29
KondratievaS CreditAttribution: KondratievaS at Skilld commentedComment #30
lauriiiThis looks pretty good already! Thank you for working on this!
The min-width should probably be 601px because the form elements are set as 100% until max-width: 600px.
Comment #31
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedHere I have tried to address comment #30.
Comment #32
kiran.kadam911Comment #33
kiran.kadam911Hello,
Tested patch #31 which works fine as per previous comment of @lauriii.
Screenshot:
Before:
After:
Thanks!
Comment #34
lauriiiThis looks great on Chrome and IE 11 but Edge could use some more work still:
Comment #35
kiran.kadam911Comment #36
kiran.kadam911@lauriii I checked the same page on IE Edge v83(browserstack) but not able to reproduce the above alignment issue as per #34
SS:
Thanks!
Comment #42
justafishHere's an alternative approach which uses the line height and margins of labels to calculate the missing space
https://git.drupalcode.org/project/drupal/-/merge_requests/131 (also this is my first go switching from patches to merge request, apologies in advance if I've done something wrong in the process here ☺️)
Chrome -
IE11 -
Comment #43
volkerk CreditAttribution: volkerk at Thunder commentedHi,
I would prefer the patch from #31
because it removes the margins on .claro-autocomplete which gives me trouble in #3194226: Add a form description toggle.
I tested the patch from #31 in edge 84 and edge 88, latest chrome and firefox esr 78 and I cannot seem to be able to reproduce the misalignment issue mentioned in #34, it also does not have the align-items issue in firefox mentioned in the mr.
Comment #44
justafishIf we remove that margin completely it causes issues elsewhere e.g.
(not that this looks perfect with the margin, but it's better 😊)
I've updated MR !131 with a fix for Firefox and the autocomplete breaking out of the container between 600px - 769px
Comment #45
volkerk CreditAttribution: volkerk at Thunder commentedAh, I can see the issue now, this made me think, maybe we could add some background to
.claro-autocomplete__message
?Before (with margin):
No additional margin, white background:
Btw. is it me or is only half of the throbber visible?
Comment #46
Abhijith S CreditAttribution: Abhijith S as a volunteer and at Zyxware Technologies commentedApplied patch #31 and it works fine. Adding screenshots below.
Before patch:
After patch:
RTBC +1
Comment #47
justafish@volkerk That's a nice solution 👍 I think this might be better moved to a separate issue? I'm sure there's a bunch of other places in the UI we'd need to test this change, plus addressing the throbber visibility issue.
Comment #48
djsagar CreditAttribution: djsagar at OpenSense Labs commentedHi @volkerk,
Patch #45 is applied and resolved the above issue but these is same issue on view content.
button is does not align with others.
Please have a look on attachment.
Thanks!
Comment #49
justafish@djsagar which patch did you apply and in what browser is that?
Comment #50
lauriiiI posted some feedback on the MR. I think that approach is good because it's getting closer to solving the root cause of this bug. ✌️
Comment #51
justafish@lauriii thanks for the review! The collapsing margin is in place so that autocomplete fields that have no label are also aligned correctly
Comment #52
lauriiiIIRC the margin was added intentionally to avoid #44. It might make sense to change the margin here, and fix it elsewhere on a follow-up since the problem caused with the loading... in edge cases where the label is very long could be less of a problem than the form elements not being aligned.
However I discovered another problem. If we remove the
align-items: flex-end
, buttons don't align with form elements without labels. But that doesn't work with descriptions and errors 🤷♂️Comment #53
lauriiiDiscussed #52 with @justafish yesterday and we found out that the problem was with me testing the change by modifying markup in the chrome developer tools rather than actually changing the Views configuration.
We also did some testing related to the loading text and we discovered some edge cases where the label totally should be still displayed as inline-block. Therefore we agreed to remove the margin-top from the .claro-autocomplete element. We also did some manual testing to ensure it doesn't break any of the other use cases. We tested autocomplete in entity references (tags style and table drags) as well as autocomplete in the entity meta column. We also did some testing before and after and this change doesn't make the loading item look any more awkward with long labels than it already looks.
I think we should open follow-up for addressing #44 still. I also posted some very minor feedback on the MR.
Comment #54
lauriiiAll of my points on the MR were addressed. Moving to RTBC. Who wants to create the follow-up?
Comment #55
ckrinaI've just created #3199351: Claro: review line-heigh usage accross components to address the line-height feedback.
And, If I’m not missing things, I can see the alignment fixed for autocomplete fields (with and without description) and working well with buttons. Here are the screenshots for Firefox:
And +1 on coming up with a solution for the loading overlapping problem into another issue too.
Comment #56
justafishHere's the follow up for the overlapping text https://www.drupal.org/project/drupal/issues/3199601
Comment #57
alexpottCommitted and pushed d9b41a883f to 9.2.x and 6bd92072ad to 9.1.x. Thanks!
Discussed with @lauriii and we agreed to backport to 9.1.x as claro is still experimental.
Comment #60
lauriiiSeems like I tagged this accidentally with "Needs change record" when I meant to tag this with "Needs followup". Removing the tag because the follow-up issue has been filed and this doesn't need change record.