Closed Bug 256856 Opened 22 years ago Closed 19 years ago

Focusing field using access key displays autocomplete popup

Categories

(Firefox :: Address Bar, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: deanis74, Assigned: martijn.martijn)

References

(Depends on 1 open bug)

Details

Attachments

(2 files, 8 obsolete files)

1. Go to http://bugzilla.mozilla.org/query.cgi 2. Type "test" in the Summary field. 3. Search. 4. Navigate back. 5. Press Alt+S to focus the Summary field. Expected Results: Summary field is focused. Actual Results: Summary field is focused and autocomplete popup drops down.
Martijn, would you be able to look at this one? My build machine is still in a shambles and I saw your patch on bug 256079.
Flags: blocking-aviary1.0?
Attached file Testcase (obsolete) —
This testcase shows that when you use the accesskey (in this testcase acc. key->s) it generates a mouseclick event (and a focus event, but that's not relevant in this bug). This is apparently on purpose, but this is different from a general mouseclick since that also generates a mousedown and a mouseup event. I guess, that's why nsFormFillController::MouseDown is never called and if you follow the logic in that code (and nsFormFillController::MouseClick) you'll see why this is creating a popup directly.
Attached patch Possible patch? (obsolete) — — Splinter Review
This seems to solve the bug. The accel key way is creating a mouseclick event, but the screenY propery = 0, so you could do an extra check on what the screenY is. But maybe this is too much of a hack?
It seems pretty hacky to me. Aaron, do you know of any way to tell if a mouseclick was triggered by an access key press instead of an actual click?
No I don't. Let's have Neil look at it. I'm incredibly swamped trying to catch up with work after attending a conference. (In reply to comment #4) > It seems pretty hacky to me. Aaron, do you know of any way to tell if a > mouseclick was triggered by an access key press instead of an actual click?
Assuming you're sticking within C++, you could define a new mouse reason code...
Another approach would be to move the showing of the popup from click to mousedown or mouseup. Actually, if we moved it to mousedown then we could get rid of the mIgnoreClick member and then I think it would also behave more like IE does. I'm not sure if it would have any negative side-effects though.
Attached patch Like this? (obsolete) — — Splinter Review
Like this? Unfortunately the patch looks a weird, but basically I'm moving all the stuff from ::mouseClick to ::mouseDown. And I'm removing some stuff, which doesn't seem to be necessary anymore. Afaics, there are no bad side-effects. What I could not solve with this patch is that when you already have an autocomplete popup on a focused input, and you click once more on the input, the popup disappears for a fraction (and then reappears) of a second on mousedown.
Attachment #157054 - Attachment is obsolete: true
Comment on attachment 157102 [details] [diff] [review] Like this? I want to make sure I'm reading the patch properly. Can you attach either a patch with more context lines or else the entire patched nsFormFillController.cpp?
Attached file nsFormFillController.cpp (obsolete) —
More context isn't helping, so I attached the whole patched nsFormFillController.cpp file.
Comment on attachment 157102 [details] [diff] [review] Like this? >Index: toolkit/components/satchel/src/nsFormFillController.cpp >=================================================================== >- mIgnoreClick = PR_FALSE; Remove mIgnoreClick from nsFormFillController.h. > nsCOMPtr<nsIDOMEventTarget> target; > aMouseEvent->GetTarget(getter_AddRefs(target)); > > nsCOMPtr<nsIDOMHTMLInputElement> targetInput = do_QueryInterface(target); >- if (!targetInput || (targetInput && targetInput != mFocusedInput)) { >+ if (!mFocusedInput || !targetInput || (targetInput && targetInput != mFocusedInput)) { Couldn't this be reduced to: if (!mFocusedInput || !targetInput || targetInput != mFocusedInput) ? >- PRBool isOpen = PR_FALSE; >- GetPopupOpen(&isOpen); >- if (isOpen) >- return NS_OK; I assume this didn't make a difference in your testing? >- if (value.Length() > 0) { >- // Show the popup with a filtered result set >- mController->SetSearchString(NS_LITERAL_STRING("")); >- mController->HandleText(PR_TRUE); >- } else { >- // Show the popup with the complete result set. Can't use HandleText() >- // because it doesn't display the popup if the input is blank. >- PRBool cancel = PR_FALSE; >- mController->HandleKeyNavigation(nsIAutoCompleteController::KEY_DOWN, &cancel); >- } >+ // Show the popup with a filtered result set >+ mController->SetSearchString(NS_LITERAL_STRING("")); >+ mController->HandleText(PR_TRUE); >+ return NS_OK; >+} > >Index: toolkit/components/autocomplete/src/nsAutoCompleteController.cpp >=================================================================== >- // Don't search if the value is empty >- if (newValue.Length() == 0) { >- ClosePopup(); >- return NS_OK; >- } >- The above two changes will change the behavior of autocomplete. If I start typing, it will display matched items. If I backspace to remove what I typed, the popup currently will close. IE behaves the same way. Your change will leave the popup open.
Attachment #157102 - Flags: review-
(In reply to comment #10) > Created an attachment (id=157109) > nsFormFillController.cpp > > More context isn't helping, so I attached the whole patched > nsFormFillController.cpp file. It turns out you didn't need to. Now I know what that "Diff" link does beside a patch...
Attached patch patch (obsolete) — — Splinter Review
Yes, sorry, I was not very clear why I removed that stuff, previously. This patch I'm attaching now follows exactly the instructions from comment 11. But with this patch applied, the autocompletepopup closes again on the 3rd, 5th, 7th, etc.. mousedown. That was something I was trying to avoid with the previous patch, but I didn't know that I was breaking something else. Again sorry. Anyhow, I don't have much experience with fixing bugs, so if someone else wants to fix this bug, be my guest.
Attachment #157102 - Attachment is obsolete: true
Attachment #157109 - Attachment is obsolete: true
Martijn, please don't be discouraged. You're doing a great job!
Comment on attachment 157154 [details] [diff] [review] patch > PRBool isOpen = PR_FALSE; > GetPopupOpen(&isOpen); > if (isOpen) > return NS_OK; I wasn't suggesting you leave this in, I was just making sure that it didn't break anything else. If you take it out, does it solve the problem of the popup closing on every other click?
No, that's what I thought, also. But that doesn't help. It would make it even slightly worse. Not only the popup closes on every other click, but on any even click -when the popup opens- the selection of the autocomplete popup drops one item lower. (and that's when I started hacking by removing more code, that was the previous patch)
Comment on attachment 157102 [details] [diff] [review] Like this? You know what? I'm fine with the behavior you had in the other patch. If a user starts entering text, the autocomplete popup drops down, and then they backspace out all the text, why not show them all their choices? I think that makes more sense than hiding the popup. Martijn, please check that this patch doesn't reintroduce bug 253709. Mike, care to review? It's a pretty simple patch that just moves some things around. There's a slight change to the functionality, but as you see I think it flows better this way.
Attachment #157102 - Attachment is obsolete: false
Attachment #157102 - Flags: review- → review?(mconnor)
Comment on attachment 157154 [details] [diff] [review] patch Obsoleting this patch in favor of attachment 157102 [details] [diff] [review]. Martijn, let me know if you disagree.
Attachment #157154 - Attachment is obsolete: true
Fine by me. But the removal of mIgnoreClick from nsFormFillController.h is not in that patch. I was thinking though. Should it not be possible to get the desired behavior for the backspace in nsFormFillController::KeyPress? I see a case nsIDOMKeyEvent::DOM_VK_BACK_SPACE there. (I'm away for the weekend, so not able to see if that would work)
This is a patch with IE-like backspace behavior, so I think you can choose now. For the rest it is (and behaves like) the same patch as "Like this?". I've tested if this regresses bug 253709, but it doesn't seem like it. I had to add not only in "case nsIDOMKeyEvent::DOM_VK_BACK_SPACE" some code, but also in nsAutoCompleteController::HandleText. When the backspace key is pressed, but there is no text anymore in the input field, the oninput DOM event is not fired, that's why the code inside "case nsIDOMKeyEvent::DOM_VK_BACK_SPACE". The code inside nsAutoCompleteController::HandleText is for the case when text is deleted until there is nothing left in the input field.
Comment on attachment 157441 [details] [diff] [review] Patch with IE-like backspace behavior Both of these work, but I'm partial to the slight change in attachment 157102 [details] [diff] [review].
Attachment #157102 - Flags: review?(mconnor)
Comment on attachment 157441 [details] [diff] [review] Patch with IE-like backspace behavior I've changed my mind. This patch is lower impact, in that it doesn't change the behavior when you backspace to clear the last letter. The only change is that the popup now appears on mousedown instead of mouseclick, which is now consistent with IE. Mike, I wrote the original code to show the popup with the mouse, and this change looks good to me. If I could r= it, I would.
Attachment #157441 - Flags: review?(mconnor)
Assignee: bugs → bryner
Flags: blocking-aviary1.0? → blocking-aviary1.0+
Not a "blocker" - re-nominate if you get review.
Flags: blocking-aviary1.0+ → blocking-aviary1.0-
Comment on attachment 157441 [details] [diff] [review] Patch with IE-like backspace behavior Mike's busy right now. Vlad, can you review?
Attachment #157441 - Flags: review?(mconnor) → review?(vladimir)
Assigning to me so I don't lose sight of this bug another time. Is there someone who can review this? (probably need to update the patch, the patch is almost a year old now. I'm wondering if this also would fix the opening of the url bar autocomplete popup when pressing Ctrl+F4 in Firefox, while the focus is in the url bar and you've only one tab left open.
Assignee: bryner → martijn.martijn
Mass edit: Changing QA to default QA Contact
QA Contact: davidpjames → password.manager
Mass edit: Setting correct QA for location bar/autocomplete. My bad. I forgot I had once been Autocomplete QA too. Hmm, why can't I just set the QA of bugs to the default QA of the component in a mass edit rather than having to do it manually...?
QA Contact: password.manager → location.bar
Attachment #157441 - Attachment is obsolete: true
Attachment #227186 - Flags: review?(bugs.mano)
Attachment #157441 - Flags: review?(vladimir)
Comment on attachment 227186 [details] [diff] [review] new patch, like previous one, updated to trunk Looks good, but this doesn't apply to current trunk. Also, please get ui-r from beltzner or mconnor.
Attachment #227186 - Flags: review?(bugs.mano)
Updated to trunk again, it should now apply cleanly again. Note, you need to use alt+shift+s on windows now for the testcase, this is something that changed with the fix for bug 340902.
Attachment #227186 - Attachment is obsolete: true
Attachment #232126 - Flags: ui-review?(beltzner)
Attachment #232126 - Flags: review?(bugs.mano)
Comment on attachment 232126 [details] [diff] [review] new patch v2, like previous one, updated to trunk Few question/issues: >Index: toolkit/components/satchel/src/nsFormFillController.cpp >=================================================================== > > PRUint32 k; > keyEvent->GetKeyCode(&k); > switch (k) { > case nsIDOMKeyEvent::DOM_VK_DELETE: Should we change the DOM_VK_DELETE accordingly as well? > #ifndef XP_MACOSX > mController->HandleDelete(&cancel); > break; >- case nsIDOMKeyEvent::DOM_VK_BACK_SPACE: >- mController->HandleText(PR_FALSE); >+ case nsIDOMKeyEvent::DOM_VK_BACK_SPACE: { >+ nsAutoString newValue; >+ mFocusedInput->GetValue(newValue); >+ if (newValue.Length() == 0) { >+ //close autocomplete popup when backspace key is pressed and when input is empty You should update the mac case as well (note: as it's written now, DOM_VK_DELETE and DOM_VK_BACKSPACE are handled the same on mac). Please comment here (in the bug) on why we no longer need to call to HandleText in the DOM_VK_BACKSPACE case. >+ // Show the popup with a filtered result set >+ mController->SetSearchString(NS_LITERAL_STRING("")); nit: s/NS_LITERAL_STRING("")/EmptyString()
Attachment #232126 - Flags: review?(bugs.mano) → review-
Comment on attachment 232126 [details] [diff] [review] new patch v2, like previous one, updated to trunk Clearing ui-review request; this just seems like a bug. The expected results are appropriate.
Attachment #232126 - Flags: ui-review?(beltzner)
Attached file updated testcase —
Attachment #157102 - Attachment is obsolete: true
Attachment #232126 - Attachment is obsolete: true
Attached patch patchv3 — — Splinter Review
Another year, another patch. This is now only moving the code into ::mousedown. The backspace bug seems fixed already, so that's why that part is removed (it was a bad idea anyway to include it into this bug, probably).
Attachment #157053 - Attachment is obsolete: true
Attachment #282439 - Flags: review?(mano)
Comment on attachment 282439 [details] [diff] [review] patchv3 r=mano
Attachment #282439 - Flags: review?(mano) → review+
Attachment #282439 - Flags: approval1.9?
Attachment #282439 - Flags: approval1.9? → approval1.9+
Checking in nsFormFillController.h; /cvsroot/mozilla/toolkit/components/satchel/src/nsFormFillController.h,v <-- n sFormFillController.h new revision: 1.17; previous revision: 1.16 done Checking in nsFormFillController.cpp; /cvsroot/mozilla/toolkit/components/satchel/src/nsFormFillController.cpp,v <-- nsFormFillController.cpp new revision: 1.90; previous revision: 1.89 done Checked into trunk.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Depends on: 398143
Depends on: 398154
Looks like this caused bug 398154.
Depends on: 477533
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: