The popup for an autocomplete field is displaced vertically by 2.5em when the field is within a fieldset (see attached image). 2.5em is significant, because it is the padding-top value of the fieldset. This can be fixed by setting the CSS position value of the div that encloses the autocomplete field to relative, rather than the default static. I have enclosed two methods of fixing this, one sets the CSS position property to relative in the seven/style.css file, whilst the other does so in the autocomplete.js file.
Note, this affects Firefox 3.6.19 on Windows and Firefox 5.0.1 on Linux, so I'm assuming it affects all versions of Firefox.
Browers Tested:
Comment | File | Size | Author |
---|---|---|---|
#42 | chrome-autocomplete.png | 123.79 KB | robpowell |
#42 | chrome-version.png | 25.41 KB | robpowell |
#42 | firefox-autocomplete.png | 41.14 KB | robpowell |
#42 | firefox-version.png | 185.82 KB | robpowell |
#10 | autocomplete2.patch | 560 bytes | droplet |
Comments
Comment #1
Caligan CreditAttribution: Caligan commentedThis doesn't happen when I test it using a tags autocomplete box on Windows/Firefox 5.0, Windows/IE 8.0, Linux/Firefox 3.6.18, or Windows/Safari 3.2.3 - I'm not sure if that indicates that the particular location of the autocomplete box I've tested it with just isn't in the same place and circumstance as yours.
Can you elaborate on the exact parameters of the autocomplete box you're using, so I can see if I can replicate the problem? The .png seems to suggest it's custom code?
Comment #2
sdrycroft CreditAttribution: sdrycroft commentedI used the attached module for testing this issue.
Comment #3
sdrycroft CreditAttribution: sdrycroft commentedTo make things a little simpler, I've created a test site to demonstrate this issue.
Comment #4
Caligan CreditAttribution: Caligan commentedI tested that site on the same set of browsers, and again don't see the displacement of the autocomplete box - it pops up exactly where it's supposed to. I think we need more input from some other people to see if anyone else can replicate this, because I can't get it to occur.
Comment #5
droplet CreditAttribution: droplet commentedBug confirmed.
Is it able to fix autocomplete.js calc the right top margin instead dependence on other elements ?
(EDIT: YES, ONLY FIREFOX HAS THIS BUG.)
Comment #6
sdrycroft CreditAttribution: sdrycroft commentedAs the issue is with the seven theme, and a patch has been supplied for it, we should leave this as an issue with 7.x-dev.
Comment #7
droplet CreditAttribution: droplet commentedalways fix head version first.
Comment #8
fagoI don't see why we should fix that in the JS, so I guess the seven patch should do it.
I'm no themer though, so setting to needs-review for others.
Comment #9
sepgil CreditAttribution: sepgil commentedI've encountered the problem with Firefox 3.6.18 on Ubuntu and Firefox 5.0 on Windows.
The Seven CSS Patch fixes the problem without creating new problems on other Browser(I've tested it on Safari 5, Opera 11, IE 9, Chrome, Fifo 5 on Windows and Fifo 3.6.18 and Chrome on Ubuntu).
I also don't see the need for the JS Fix.
Comment #10
droplet CreditAttribution: droplet commentedJust like a modules, less dependence is always good for it.
e.g. adding position: relative;, it limited someone using position: absolute on .form-item to theme the elements.
Im more like fixing in this way (attached patch)
Comment #11
sdrycroft CreditAttribution: sdrycroft commentedThe JS patch was merely supplied as an alternative to the autocomplete patch.
I've actually found that the patch I provided causes issues with autocomplete fields in blocks. The following patch fixes this, as an alternative to droplet's patch in comment #10.
Comment #13
anniegreens CreditAttribution: anniegreens commentedI can confirm this is happening in FF 6.0.2 on Mac OS 10.6.8.
Comment #14
droplet CreditAttribution: droplet commentedComment #15
sdrycroft CreditAttribution: sdrycroft commented#11: autocomplete_popup_position-1218684-11.patch queued for re-testing.
Comment #16
hutch CreditAttribution: hutch commentedI have tried both the css and js #11 method and both work, however the css method is too broad as it applies the positioning to all instances of .form-item which may have implications.
It seems to me that a better solution would be (as in #11) to replace
with
and add some css to system.base.css
I have tried this and it works fine.
This way themers can override and everyone is happy ;-)
I will leave patch building to those more closely involved with core than I am.
Comment #17
DanChadwick CreditAttribution: DanChadwick commentedI ran into this in bartik. Perhaps the issue's Component should be changed to the form system?
In Drupal 7.12, the autocomplete was positioned at the top left of the window using windows Firefox 10.0.1. It positioned correctly IE9. Placing it in a relative positioned div as described above worked.
Comment #18
tirdadc CreditAttribution: tirdadc commented#11 works perfectly, I was experiencing this on both Firefox and Chrome with a custom modal window that contains some node references.
Comment #19
lumbric CreditAttribution: lumbric commented#11 solved the issue for me. Tested with:
Drupal: 7.14
Browsers: Firefox 15.0.1 for Ubuntu, Chromium Version 20.0.1132.47 Ubuntu 12.04 (144678)
Themes: Seven, Bartik
Comment #20
droplet CreditAttribution: droplet commentedComment #21
Rob230 CreditAttribution: Rob230 commentedThis was an issue for me in D7. When having an autocomplete field in Bartik I was finding the following behaviour:
#11 fixed it in all browsers, although I think you can just say
$input.parent()
.$($input)
is redundant.Thanks.
Comment #22
aangel CreditAttribution: aangel commented#11 with the change recommended by Rob230 (just $input) did the trick in my 7.15 installation.
Comment #23
protools CreditAttribution: protools commentedDrupal 7.22 patch from #11 work for me Firefox and Chrome
I think good idea from @hutch in #16
Comment #24
thoughtcat CreditAttribution: thoughtcat commentedPatch in #11 worked perfectly! Thank you :)
Comment #25
ryantollefson CreditAttribution: ryantollefson commentedAlso Bartik. #11 worked for me. Thanks!
Comment #25.0
ryantollefson CreditAttribution: ryantollefson commentedAdded link to attached image.
Comment #26
ianthomas_uk#16 mentions some problems with #11 which need to be addressed.
We will need a patch to be committed to 8.x before a 7.x patch will be considered.
Comment #27
mgiffordIs this still an issue? I wasn't able to replicate it in D8. Core's changed so much that the patch is irrelevant at this stage for D8.
It is quite possible that with leveraging jQuery UI's autocomplete that this problem has been fixed in D8.
Which brings us back to D7 and the patch in #11.
Comment #28
ianthomas_ukAutocomplete has been replaced in D8, so it's not surprising that you can't reproduce this any more. It does still need to be fixed on D7 though (assuming this is the same issue as #2132107: The autocomplete drop-down in the related issues section of the issue edit form pops-up far from the field... or can otherwise still be reproduced)
Comment #29
droplet CreditAttribution: droplet commentedD8 using jQuery UI now, should not have any problems.
I don't want to repeat my word but seems like most commenters just look at the last patch #11. And Yes. Both #10 & #11 sorted the problem. However, I still think my patch #10 is the best solution right now. Because it lets themer to add "position: absolute" to the parent element. (jQuery UI does the same way)
Patch #11 doesn't address this problem. Comment #16, moving style only let CSS guy theming it easily. On Patch #11, when you adding "position: absolute" to parent, it's broken again.
Comment #30
droplet CreditAttribution: droplet commentedAdd it back
Comment #31
droplet CreditAttribution: droplet commented10: autocomplete2.patch queued for re-testing.
Comment #32
dcmouyard CreditAttribution: dcmouyard commentedI prefer the approach in #10, but it will likely break when inside a CTools modal dialog because they override the top property via JS. A new bug will have to be created in the CTools issue queue when this is committed.
Comment #33
quotesBro CreditAttribution: quotesBro commentedI found the duplicate (with patch similar to #16)
Comment #34
chrisolof CreditAttribution: chrisolof commentedI've got a patch on #2157907 for 7.x (mentioned in #33) which I believe is very unobtrusive and allows for easy overriding. Here's a summary:
The patch in #2157907 fixes the bug by positioning the autocomplete popup's parent element relative while the popup is open.
This is achieved by defining "position: relative;" for the class "autocomplete-parent" in system.base.css and adding that class to the autocomplete popup's parent element (via autocomplete.js) when the popup is open. When the popup is removed, so is the class on the parent element.
So the fix basically shows up only when it's needed and works via class toggling (no inline styling) so it's completely override-able.
I can roll an 8.x patch if this sounds like a good route.
Comment #35
droplet CreditAttribution: droplet commented@chrisolof,
Read #29
Comment #36
chrisolof CreditAttribution: chrisolof commented@droplet - Good catch - I, for some reason, thought this was an 8.x bug. I'll try and test your patch in #10 against the issue I outlined in 2157907, as they're probably related. If it doesn't fix both issues I'll probably just re-post my patch here too.
Comment #37
chrisolof CreditAttribution: chrisolof commentedI can no longer reproduce this bug on my system, nor can I reproduce the related bug I outlined in #2157907. I'm thinking this may no longer be an issue for users on current browsers.
Comment #38
droplet CreditAttribution: droplet commented@chrisolof,
this is for D7. We still have to fix it for older browsers. :(
Comment #39
R13ose CreditAttribution: R13ose commentedComment #40
oleg.medvedev CreditAttribution: oleg.medvedev as a volunteer commentedComment #41
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedIt is not clear to me which patch is being marked RTBC (#10 or #11), what testing has been done, or whether any of the discussion above has been resolved....
I also can't reproduce any issue here (using Firefox 50 on Linux). If it does turn out this was a browser bug which Firefox fixed in more recent versions, I don't see any reason we need to do anything about it on our end.
Comment #42
robpowellI reviewed 7.69 on simplytest for both chrome and firefox. Here is what I did:
* add terms: term1, term2, and term3 to the Tags vocab
* add new article (tag field has widget set to Autocomplete term widget (tagging))
* select terms
Here is the simplytest link for those that see it in the next 24hrs, https://stm5e0a0cb299bb8-jqirou3dubgkwotuzdxnhrjgshgxmlvd.tugboat.qa/.
I believe this can be closed as it no longer seems to be an issue.