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.
When 'Enter' key being pressed nn search forms (template and search block), it posts nothing just refreshes the page. I have to click search button using the mouse, or use TAB to focuse it before pressing Enter.
Comment | File | Size | Author |
---|---|---|---|
#63 | ie_submit_5.patch | 1.05 KB | theborg |
#62 | ie_submit_4.patch.txt | 923 bytes | Gábor Hojtsy |
#60 | ie_submit_3.patch | 842 bytes | theborg |
#51 | ie-submit_2.patch | 1.1 KB | theborg |
#50 | ie-submit.patch | 682 bytes | catch |
Comments
Comment #1
RobLoachI'm not experiencing this issue in either Beta 3 or 6.x-dev. Mind testing it in 6.x-dev? What browser are you using?
Comment #2
ssb-1 CreditAttribution: ssb-1 commentedI'm using IE7.
After entering some keywords and pressing enter just do nothing. If manually focus (using TAB) the search button, enter key works just fine. Same if clicked the button with mouse.
Comment #3
ssb-1 CreditAttribution: ssb-1 commentedComment #4
RobLoachThe issue is Internet Explorer under Windows. It happens in IE6 and IE7 in both the Search block and the Search page. Damn browsers cause so many problems. Works in every other browser...
Comment #5
ssb-1 CreditAttribution: ssb-1 commentedProblem still exists in latest Drupal 6.0 - beta4.
Comment #6
ssb-1 CreditAttribution: ssb-1 commentedTested and happens with both IE6/7 and all Drupal 6.0 betas (including b4).
With Enter key, it behaves like it found nothing although after clicking "Search" button works giving results. Very annoying.
Comment #7
chx CreditAttribution: chx commentedComment #8
ssb-1 CreditAttribution: ssb-1 commented@chx:
Sorry but did you check this issue before decreasing priority to minor?
If not, please do. It is not just a simple button focus problem but a quite serious issue. Most users are using 'Enter' key after typing some search keywords. Drupal accepts key pressed, but return no searching results. Do you really think this issue as "minor"?
Comment #9
Gábor Hojtsyssh: critical is reserved to far more important problems. Like you cannot edit your menu items.
Comment #10
ssb-1 CreditAttribution: ssb-1 commented@Gábor Hojtsy: As you wish, as long as this will get fixed before 6.0 release...
Comment #11
Gábor Hojtsyssb: this search form is not new and it probably had the same bug for a few releases. If not, and previous ones worked better, feel free to analyze and come up with what's different and what needs to be fixed. This bug will surely be fixed in Drupal if someone provides a working patch. Otherwise not.
Comment #12
catchhttp://drupal.org/node/199198 was duplicate.
Comment #13
ssb-1 CreditAttribution: ssb-1 commentedThis issue still exists in rc2.
Anybody could check this? With all my respect to Drupal developers, you might consider this issue as minor but it's a show stopper for all my users.
Comment #14
sunfish62 CreditAttribution: sunfish62 commentedAccording to http://www.upsdell.com/BrowserNews/stat_trends.htm (Jan 5, 2008):
I agree with ssb. While I do NOT like IE, it is a reality, and Drupal developers ignore it unwisely.
Comment #15
Gábor Hojtsysunfish62: who ignores this? We said we are open to dicussing fixes and improvements. First is to check whether this is new in Drupal 6, as I noted above.
Comment #16
ssb-1 CreditAttribution: ssb-1 commentedGabor, sorry but although we do love Drupal, not all of us are php developers to contribute patches. However you cannot ignore or consider as minor a serious issue that bothers the "majority" of web users.
BTW, this is new issue in Drupal 6, v5.xx works just fine.
Comment #17
Gábor Hojtsyssb: Although some of us probably have better PHP experience then you do (not that there is any PHP experience required here), we might not have an Internet Explorer install to test with. So there needs to be some cross between those who can reproduce the bug in Internet Explorer and those who can look into fixing it.
I have IE6 installed on my Mac OS X with IEs4OSX (http://hojtsy.hu/blog/2007-dec-24/ies4osx-saved-drupal-hu-christmas) and went ahead to test the search block form. When I clicked on the search input field in Drupal 5, the search button was automatically selected and the submission went fine. The same did not happen on Drupal 6. So reproduced.
Now let's see what happens in the HTML (note there is no elit PHP skills required here, just copying source from browser): http://drupalbin.com/464
Look, the difference is that the submit action is different. In Drupal 5, it is always the node form, in Drupal 6 it is always the same URL. Well. Now go check why it works when you click the button, not press enter. Since the HTML form is the same, the browser initiated action should be different. This is an issue somewhere on the browser side, possibly JavaScript.
Sorry, but I am not a JS guru, and a quick search for submit handlers in the Drupal source code did not turn up anything either. Feel free to take it on from here.
Comment #18
catchA related bug may be that the search block doesn't appear to work on the same page as the search form (via theme) - although iirc that's a drupal 5 issue as well. Will try to look into that a bit closer later on.
edit: well I didn't check 5, but it's no longer an issue on 6.x if it ever was.
Comment #19
ssb-1 CreditAttribution: ssb-1 commentedHmm, i doubt that is a Javascript issue. The problem occures even with JS disabled.
Comment #20
catchI think I might have tracked this down.
IE7 apparently treats
name
andid
exactly the same: http://remysharp.com/2007/02/10/ie-7-breaks-getelementbyid/The html for the search form has name and id both set to
search-theme-form
on different elements.Not to mention the duplicate id code seems to have added -1 to the textfield id as well, which probably doesn't have anything to do with this, but it shows these are a bit too closely named.
(note, no php knowledge required).
Comment #21
catchThe search block form has exactly the same issue, except the id/names are
search_block_form
instead.Comment #22
catchThis is likely to affect any javascript dependent on ids as well. Moving to forms system.
Comment #23
leotemp CreditAttribution: leotemp commented*scratching primate like head* So.. is there a recommended solution to this or just use the forms api instead?
Comment #24
catchNo solution yet no, I may not have even identified the bug correctly.
What you could do is copy the search-theme-form.tpl.php file into your theme, then change the id to something else, see if that fixes it.
Comment #25
dvessel CreditAttribution: dvessel commentedcatch, that's an interesting find on names and id's. It's either that or the UTF character encoding. See below.
I just tested on Drupal 5 and can't reproduce with IE7. I'm guessing it'd be the same with IE6. I would have noticed by now with all my testing with Drupal 5 since I *always* press return.
Here's the markup for the search box in Garland:
Drupal 5.2
Drupal 6.dev
BTW, code formatting is broke. Had to encode this post.
[edit: code formatting is fixed. decoded post.]
Comment #26
catchI see
search-theme-form-keys
on the 5.x search module and no duplicates. Any reason we can't change 6.x to that?Comment #27
dvessel CreditAttribution: dvessel commentedYeah, I think that'll fix it. I just checked with fiddler and string that's sent are these. Not sure I'm using it right but this looks like the culprit.
6:
5:
Note the dupes. Catch nailed it.
Comment #28
dvessel CreditAttribution: dvessel commentedTook another look and it was me who broke it during the template conversion. hehe
This workaround was originally in 5 but the comments were completely off on why it was there so I removed it. Here it is again with a more descriptive comment.
Comment #29
dvessel CreditAttribution: dvessel commentedComment #30
dvessel CreditAttribution: dvessel commented@ssb, you think this is important? How about testing it so it can go in.
Comment #31
ssb-1 CreditAttribution: ssb-1 commentedNope, didn't work.
After applied patch, I've cleaned cache and rebuilt index just for sure, but the problem persists.
Comment #32
catchssb is right, same behaviour in IE7 patched as unpatched :| changing title since this clearly isn't the problem.
Comment #33
dvessel CreditAttribution: dvessel commentedWell Damn.! I'm stumped. For anyone more knowledgeable here's the POST data gathered from Fiddler.
IE in Drupal 5 and FF 2 in Drupal 6 shown below for reference.
IE7 in Drupal 6 –the problem:
IE7 in Drupal 5 –OK:
FF2 in Drupal 6 -OK:
Comment #34
ssb-1 CreditAttribution: ssb-1 commentedAny progress on this issue?
I don't want to rush things but I'm afraid that this problem will not be fixed before Drupal v6.0 final.
Comment #35
catchI have to say although this doesn't actually break anything, it's going to lead to a lot of annoyance for a lot of visitors, and hence support requests and the rest, so would be good to get it fixed before release.
Comment #36
ssb-1 CreditAttribution: ssb-1 commentedPatch not working, thus status changed to active!
Comment #37
theborg CreditAttribution: theborg commentedThis is an idea: we can emulate the submit button asigning an action to the search form. The problem is that the post key value is not passed.
Comment #38
ssb-1 CreditAttribution: ssb-1 commentedNice idea but unfortunately didn't work.
Comment #39
David_Rothstein CreditAttribution: David_Rothstein commentedI did some Googling and apparently it turns out that IE has some "issues" when it comes to forms that have only one input field:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=903924&SiteID=1
http://kentreis.wordpress.com/2007/09/08/one-field-forms-and-ie-quirks/
So......... um, the following patch gives whole new meaning to the concept of "code needs work" ;) But it does fix the problem. (Actually, only 2/3 of the problem. When I tested with IE7, the search block works fine, as does the user search, but the main search form at /search/node is still broken - apparently the existence of the Advanced Search fieldset is giving it problems for some reason?)
As for how to fix this for real, I have no brilliant ideas, unfortunately.
Comment #40
David_Rothstein CreditAttribution: David_Rothstein commentedOh, also, the first link I posted claims that this issue only occurs when the form action is the same as the current page (I guess that would explain why it's not a problem in Drupal 5). So maybe something along the lines of @theborg's patch is the way to go?
Comment #41
ssb-1 CreditAttribution: ssb-1 commentedHmm, you may be right David, I've read about it a few months ago but never experienced such a problem before.
Although your patch works, I'm afraid it's only a workaround. Putting a second textfield on each single entry form looks like an ugly hack.
Comment #42
Bence CreditAttribution: Bence commentedYou could use a hidden input type with conditional comments, that is not so ugly...
or you can add some javascript to the one field that you do have
<input type='text' onkeydown='if(event.keyCode==13) this.submit()' />
(the "this" object in the example above would need to be a reference to the form itself).
Comment #43
ssb-1 CreditAttribution: ssb-1 commentedSearching around I've found this in Drupal 6 API: http://api.drupal.org/api/function/_form_builder_ie_cleanup/6
According to that, this IE issue is known to Drupal forms developers. They use _form_builder_ie_cleanup function to handle it.
It looks that there is a bug in _form_builder_ie_cleanup code. BTW Drupal 5 doesn't use this function...
Comment #44
catchssb, nice find!
It's a typo in _form_builder_ie_cleanup.
Changed a
!empty
toempty
and it works for me now, except I get anundefined index buttons
error along with it.So still needs work, but getting close now.
Comment #45
ssb-1 CreditAttribution: ssb-1 commentedI think I've found something.
In includes/form.inc line 892-893, the buttons collection ($form_state['buttons']) is unset.
Commenting out this line fix the problem on both sidebar search box and search form.
I have no PHP experience so please review this fix.
Comment #46
catchOK new patch fixes the notice by wrapping it in an isset. Might be a problem elsewhere, in which case this'd be a hack, but marking to CNR.
edit: cross posted with ssb. I didn't have any luck commenting out the unset() - this is my first ever look at form.inc though so any help much appreciated past this point!
Comment #47
Gábor HojtsyHm, if the form state buttons array's submit key is empty, how could its 0th index lead us to a button? The !empty() checked whether there are submit buttons on the form I guess.
Comment #48
catchThis is much more general than search submission so retitling.
Comment #49
qray CreditAttribution: qray commentedSSB's solution works great for me. After commenting out unset($form_state['buttons']); in forms.inc, all search fields (forms & boxes) work with Ie6/7 and other browsers.
Nice find!
Comment #50
catchSorry! I just tried ssb's solution on a clean install and it works fine. Here's a patch which just removes the unset. I'm not sure if this should be moved elsewhere though, but leaving at needs review for now. Don't credit me if this gets in, just patchifying ssb's solution.
edit: ack! right patch this time.
Comment #51
theborg CreditAttribution: theborg commentedRepatching ssb's and catch. Just added the unsetting to the cleanup function.
Comment #52
catchFor some reason I tried this earlier but was unsuccessful. Anyway, tested this and it works great. Very small change in the end, so marking RTBC, since although I made patches during the issue, none of this final code has anything to do with me :)
Comment #53
David_Rothstein CreditAttribution: David_Rothstein commentedIt's still not working for me on the main search content page (i.e., at /search/node)... Anyone else see this too? For the search box and user searches it works great, though. Nice!
Comment #54
catchOops.
If I expand the 'Advanced Search' fieldset (which has another submit button) it works patched or unpatched. Without that fieldset expanded, nothing.
Comment #55
David_Rothstein CreditAttribution: David_Rothstein commentedThe /search/node problem may be a separate issue, actually? (And probably not "criticial" since I just checked and it exists in Drupal 5.x as well.) The reason I say this is that it seems to exhibit different behavior. For the others, hitting Enter caused the page to reload without submitting the form. At /search/node, hitting Enter seems to literally do nothing...
Comment #56
ssb-1 CreditAttribution: ssb-1 commentedStrange, It works fine for me.
I've tested search box in sidebar, theme search and main search content page (/search/node) with and without advanced settings. No problems at'all.
One problem I've noticed is with main search content page when advanced search is enabled. However this is unrelated to the problem we examine. In this case "Search" button has no focus thus enter key doesn't work. Same happens with Drupal 5.xx (and 4.xx if my memory serves me well); you can test it with drupal.org.
To conclude, I believe we have to commit this patch and open a second issue on the advanced search focus problem.
Comment #57
catch#55, yes "literally nothing" is what I experienced, so yeah let's move that to a new issue once this gets in.
Comment #58
webchickSorry. That was bugging me. :P
I would test but I don't have IE.
Comment #59
Gábor HojtsyHm, this only removes the buttons in the IE case, otherwise it leaves the buttons there. Is this the intended behavior? Looks like this has some side effects on what is available in the form. Previously buttons were always unset after the clicked button was recognized. So does the solution to the bug at hand is that we need to keep the button information? It is unclear to me how does this work.
Comment #60
theborg CreditAttribution: theborg commentedOk Gábor, this has sense to me.
I've changed the unset to where it was before, but added a test on form submition to see if ie_cleanup has done the work on the buttons array.
Comment #61
catchTested, and this works great. Can't see this having any side-effects so back to rtbc.
Comment #62
Gábor HojtsySorry, but I am trying to understand what happens here. The "After handling the special IE case, we no longer need the buttons collection." does not say much in why we only remove it in certain cases. What happens with it if we don't remove it. Why do we need to keep it? What happens with it later?
Attached a patch which tries to be more to the point with a "If we already know which button was submitted, we don't need the buttons." comment. (Note that we already know we are after the IE case, so no need to repeat that). But this still does not explain why is it left otherwise. How is the clicked button identified in that case?
This bug took so much work to resolve, so why not document what we found, so later others will know better?
Comment #63
theborg CreditAttribution: theborg commentedIndeed Gábor, now it has a better understanding, moving this to RTBC.
Edit: added some more explanation about the buttons array issue, and punctuation (Keith Smith).
Comment #64
Gábor HojtsySounds much better. Thanks, now committed!
Comment #65
David_Rothstein CreditAttribution: David_Rothstein commentedI just posted a new issue about the separate problem with /search/node (discussed in #53-#57 above):
http://drupal.org/node/214292
Comment #66
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #67
NewDays CreditAttribution: NewDays commentedI am not comfortable implementing this patch. Not sure how other than copying and pasting what will read...
I know that // is comment, but what about the - or +, or @@,+++ etc...
Newbie needs some help.
-----------------------------------------------
I was writing code for my own search box querying the database for specific case and found that when I pressed enter it would send me back to the homepage. Pressing the button would run the search but enter key would not do it even if the button was highlighted. I then checked for the keycode 13 during a keypress event, then calling the same javascript, in this instance gotostore(), that pressing the button called. The event handler worked but calling the jscript, I didn't submit a form. The input is in a form and the button submits values, the code is below.
Any help or suggestions would be appreciated. I thought is was just a form submit issue, which i will do from the
portion of the page, to see for sure. The .inc file, I need to know how to add patches mainly.