Closed
Bug 995758
Opened 11 years ago
Closed 9 years ago
Address bar doesn't capture focus if a new tab is created via Ctrl+T shortcut while in Customization mode
Categories
(Firefox :: Toolbars and Customization, defect, P5)
Tracking
()
VERIFIED
FIXED
Firefox 48
Tracking | Status | |
---|---|---|
firefox48 | --- | verified |
People
(Reporter: jaramat, Assigned: ralin)
References
Details
(Whiteboard: p=0 [Australis:P4-] [qx:link:spec])
Attachments
(2 files, 2 obsolete files)
(deleted),
patch
|
Gijs
:
review-
|
Details | Diff | Splinter Review |
(deleted),
patch
|
Gijs
:
review+
|
Details | Diff | Splinter Review |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0
Steps to reproduce:
Enter Customization mode via PanelUI menu/right click - Customize.../or about:customizing. Press Ctrl+T to open a new tab.
Expected results:
New tab opens, and the address bar receives focus so the user can type address right away.
Actual results:
New tab opens, but the address bar isn't active until the user manually activates it.
Additionally, the same goes for Ctrl+K shortcut. When pressed, it quits Customization mode, but doesn't activate the Search bar.
Tested in latest Nightly 31.0a1 (2014-04-13), but this bug might be reproducible in Aurora and Beta as well.
Marked as trivial because this is a minor bug, and I don't expect many users to open a new tab from Customization mode anyway.
Comment 1•11 years ago
|
||
Confirmed 31.0a1 (2014-04-14), Win 7 x64.
Updated•11 years ago
|
Flags: firefox-backlog+
Whiteboard: p=0
Updated•11 years ago
|
Whiteboard: p=0 → p=0 [Australis:P4-]
Updated•10 years ago
|
Whiteboard: p=0 [Australis:P4-] → p=0 [Australis:P4-] [qx]
Comment 2•10 years ago
|
||
For the urlbar, it looks like the focusAndSelectUrlBar function at https://dxr.mozilla.org/mozilla-central/source/browser/base/content/browser.js#1945 is failing. In particular, the call to gURLBar.select() isn't selecting the gURLBar. I suspect that if the current url is "about:customizing", we will need to wait for an event before we call focusAndSelectUrlBar…
I tried:
gNavToolbox.addEventListener("customization-transitionend", …);
and:
gNavToolbox.addEventListener("customizationend", …);
But those both seemed to fire before the urlbar was unwrapped. Maybe Gijs will know what event we should be waiting for is, so that we can call focusAndSelectUrlBar and have it actually focus the urlbar. :)
Flags: needinfo?(gijskruitbosch+bugs)
Comment 3•10 years ago
|
||
(In reply to Blake Winton (:bwinton) from comment #2)
> For the urlbar, it looks like the focusAndSelectUrlBar function at
> https://dxr.mozilla.org/mozilla-central/source/browser/base/content/browser.
> js#1945 is failing. In particular, the call to gURLBar.select() isn't
> selecting the gURLBar. I suspect that if the current url is
> "about:customizing", we will need to wait for an event before we call
> focusAndSelectUrlBar…
>
> I tried:
> gNavToolbox.addEventListener("customization-transitionend", …);
> and:
> gNavToolbox.addEventListener("customizationend", …);
>
> But those both seemed to fire before the urlbar was unwrapped. Maybe Gijs
> will know what event we should be waiting for is, so that we can call
> focusAndSelectUrlBar and have it actually focus the urlbar. :)
"aftercustomization" on gNavToolbox should work? ( from http://mxr.mozilla.org/mozilla-central/source/browser/components/customizableui/CustomizeMode.jsm#480 which is gCustomizeMode.exit)
You'd need to detect this by checking if the urlbar is in a toolbarpaletteitem, I guess...
(you could theoretically also check if it's disabled, but that likely won't be futureproof if we ever start disabling it for other reasons)
Flags: needinfo?(gijskruitbosch+bugs)
Updated•10 years ago
|
Whiteboard: p=0 [Australis:P4-] [qx] → p=0 [Australis:P4-] [qx:link:spec]
Updated•9 years ago
|
Updated•9 years ago
|
Priority: -- → P5
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → ralin
Assignee | ||
Comment 4•9 years ago
|
||
Hi Gijs,
There's a serial of async tasks in gCustomizeMode.exit which to finish up Customization Mode, therefore focusAndSelectUrlBar will be triggered before exact gURLBar is ready.
As you said, listening to "aftercustomization" would able to focus gURLBar at right timing. This patch simply adds a listener to the event though I can not be sure if it is appropriate to handle this in the function. Could you give me some feedback? Thanks!
Attachment #8736257 -
Flags: feedback?(gijskruitbosch+bugs)
Comment 5•9 years ago
|
||
Comment on attachment 8736257 [details] [diff] [review]
Bug-995758-Focus-new-tab-URLBar-in-Customization-mod.patch
Review of attachment 8736257 [details] [diff] [review]:
-----------------------------------------------------------------
Well, the callsite in this case seems to be from utilityOverlay.js' openLinkIn and friends, and that seems liable to change as well, so I guess that this is probably the most appropriate solution. Maybe you can add a comment about why we're doing this?
::: browser/base/content/browser.js
@@ +1831,5 @@
> }
>
> function focusAndSelectUrlBar() {
> + if (CustomizationHandler.isExitingCustomizeMode &&
> + CustomizationHandler.isCustomizing()) {
Isn't just the first check here (for isExitingCustomizeMode) sufficient ?
@@ +1834,5 @@
> + if (CustomizationHandler.isExitingCustomizeMode &&
> + CustomizationHandler.isCustomizing()) {
> + gNavToolbox.addEventListener("aftercustomization", function afterCustomize() {
> + if (gURLBar) {
> + gURLBar.select();
Hm, well, this should probably just re-call focusAndSelectUrlBar, because we need to handle the full screen case as well (you can be in full screen *and* in customize mode).
Attachment #8736257 -
Flags: feedback?(gijskruitbosch+bugs) → feedback+
Assignee | ||
Comment 6•9 years ago
|
||
Thanks for your feedback, Gijs. Could you help me to review this patch?
Attachment #8736257 -
Attachment is obsolete: true
Attachment #8737072 -
Flags: review?(gijskruitbosch+bugs)
Comment 7•9 years ago
|
||
Comment on attachment 8737072 [details] [diff] [review]
Bug-995758-Focus-new-tab-URLBar-in-Customization-mod.patch
Review of attachment 8737072 [details] [diff] [review]:
-----------------------------------------------------------------
::: browser/base/content/browser.js
@@ +1831,5 @@
> }
>
> function focusAndSelectUrlBar() {
> + // Bug 995758 - Capture focus if a new tab is created via Ctrl+T shortcut
> + // while in Customization mode
The comment should explain why there is code here, not just reference the bug and its summary. The shortcut part of this is also not really important. Explain *why* we need to wait with the focusing of the URL bar until customization mode has finished.
@@ +1835,5 @@
> + // while in Customization mode
> + if (CustomizationHandler.isExitingCustomizeMode) {
> + return gNavToolbox.addEventListener("aftercustomization", function afterCustomize() {
> + focusAndSelectUrlBar();
> + gNavToolbox.removeEventListener("aftercustomization", focusAndSelectUrlBar);
This doesn't work - you added an event listener referencing the 'afterCustomize' function, not the focusAndSelectUrlBar one, so you should remove the right listener.
Also, please put the listener removal before the call to focusAndSelectUrlBar. If the latter throws, for some reason, we wouldn't remove the listener, and that would be bad.
@@ +1836,5 @@
> + if (CustomizationHandler.isExitingCustomizeMode) {
> + return gNavToolbox.addEventListener("aftercustomization", function afterCustomize() {
> + focusAndSelectUrlBar();
> + gNavToolbox.removeEventListener("aftercustomization", focusAndSelectUrlBar);
> + });
The previous patch returned true; why are you returning the result of the addEventListener call (undefined) now?
Attachment #8737072 -
Flags: review?(gijskruitbosch+bugs) → review-
Assignee | ||
Comment 8•9 years ago
|
||
Thank for your reviewing, Gijs.
I've updated the patch, could you please review it again? Thanks!!
Please feel free to correct me if anything can be better, it helps me improve myself.
Attachment #8737148 -
Flags: review?(gijskruitbosch+bugs)
Comment 9•9 years ago
|
||
Comment on attachment 8737148 [details] [diff] [review]
Bug-995758-Focus-new-tab-URLBar-in-Customization-mod-v2.patch
Review of attachment 8737148 [details] [diff] [review]:
-----------------------------------------------------------------
::: browser/base/content/browser.js
@@ +1831,5 @@
> }
>
> function focusAndSelectUrlBar() {
> + // If we open a new tab in CustomizeMode, this function will be called
> + // before new tab's URLBar is ready. Therefore, we need to wait for the
Instead of "is ready", can we describe more precisely what is happening? How about:
In customize mode, the url bar is disabled. If a new tab is opened or the user switches to a different tab, this function gets called before we've finished leaving customize mode, and the url bar will still be disabled. We can't focus it when it's disabled, so we need to re-run ourselves when we've finished leaving customize mode.
@@ +1840,5 @@
> + gNavToolbox.removeEventListener("aftercustomization", afterCustomize);
> + focusAndSelectUrlBar();
> + });
> +
> + return true;
Did you test this change and the previous version of this patch (that returned the result of addEventListener)? Can you explain why we're returning true rather than false/falsy-values? It seems like the callsites use the return value, so it is not unimportant to get it right, for some meaning of the word. :-)
Attachment #8737148 -
Flags: review?(gijskruitbosch+bugs)
Assignee | ||
Comment 10•9 years ago
|
||
The comment is much more precise than mine. :)
I think focusAndSelectUrlBar explicitly returns value is because some functions use it to decide next action. The case return false is only when gURLBar is unavailable, so we need to ensure behavior retains consistency.
I made comment change to patch, and I'm grateful to have your guidance and explanation . Could you help me to review again? Thanks!!
Attachment #8737148 -
Attachment is obsolete: true
Attachment #8738380 -
Flags: review?(gijskruitbosch+bugs)
Comment 11•9 years ago
|
||
Comment on attachment 8738380 [details] [diff] [review]
Bug-995758-Focus-new-tab-URLBar-in-Customization-mod-v3.patch
Review of attachment 8738380 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks!
Attachment #8738380 -
Flags: review?(gijskruitbosch+bugs) → review+
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 12•9 years ago
|
||
Keywords: checkin-needed
Comment 13•9 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox48:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 48
Comment 14•9 years ago
|
||
I've managed to reproduce this bug on Nightly 31.0a1 (2014-04-14) on Linux, 64 Bit.
This Bug is now verified as fixed on Firefox Developer Edition 48.0a2 (2016-05-09)
Build ID: 20160509004024
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0
OS: Linux 4.4.0-21-generic x86-64
QA Whiteboard: [bugday-20160511]
Updated•9 years ago
|
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•