Open Bug 1411465 Opened 7 years ago Updated 10 months ago

browser.tabs.update with URL places focus in URL bar rather than loaded content

Categories

(WebExtensions :: General, enhancement, P5)

enhancement

Tracking

(firefox57 wontfix)

Tracking Status
firefox57 --- wontfix

People

(Reporter: bugzilla, Unassigned)

References

Details

(Whiteboard: [design-decision-needed])

When you press the "Home" button, Firefox loads the homepage in your current tab and gives focus to the content, e.g. in the case of Google, the search field receives focus. If I try to do this via browser.tabs.update(), the cursor goes into the URL bar instead, prior to the URL. This request is similar, but subtly different to the request in bug 1409675, which suggests that the value in the URL bar should be selected. Would it be possible to add an additional option to browser.tabs.update() so we can specify this behaviour? Something like browser.tabs.update({"url": "google.com", "focus": "content"}); With possible options: "content" - the loaded page "url" - the URL bar (which should also select the text in full, as per bug 1409675) I can't think of any good reason to have an option for just plonking the cursor at the start of the URL as it does now. This is literally the most requested feature for my New Tab Homepage add-on, to the tune of probably hundreds of emails historically. I thought I had a way to do it with Web Extensions (via browser.tabs.executeScript) but it doesn't work. I note that the (web ext) add-on New Tab Override works around this by removing the tab that was just opened and creating a new one, so browser.tabs.create() provides focus to content in the way you would expect. I'm reluctant to implement this workaround because it's pretty jarring UI behaviour.
Just to add to the above, middle clicking the home button also exhibits the behaviour you'd expect, e.g. focus is given to content when the new tab is opened.
Priority: -- → P5
Whiteboard: [design-decision-needed]
Severity: normal → enhancement
User Story: (updated)
(sorry, accidentally put this in the user story. again [unfortunately it is the first large text field in w3m]. moving.) I found this bug by way of the comments section of New Tab Homepage 0.6.2 which I was using to fix ctrl-t by having it set the new tab to about:blank - for some reason making new tab blank is something that Firefox preferences did not previously support. However, about:blank was not selected and cursor was focused at the end which caused me to repeatedly reflexively (due to decades of muscle memory) paste the url after about:blank and get a 404. And the bug referenced from this bug about auto-selecting the URL (about:blank in my case) was closed WONTFIX. Anyway! While I much appreciate what New Tab homepage was doing, I just wanted to let people know that in Nightly you can now choose between an arbitrary url, about:blank and "firefox home" for new tab spawning. And the about:blank Firefox spawns has an empty url bar which is just about perfect. So... this addon might have been obsoleted? Are there other use cases it can cover? Just wanted to mention.
User Story: (updated)
Other functionality not provided by default FF: New Tab = local file. The above FF fix only allows URLs.
(In reply to nemo from comment #4) > So... this addon might have been obsoleted? Are there other use cases it can > cover? Just wanted to mention. I would be happy for it to be obsoleted. When I first developed it (in 2003) I did not expect it to survive 15 years before the functionality was implemented in Firefox. That doesn't really change the legitimacy of this bug, however. (In reply to guzzy from comment #5) > Other functionality not provided by default FF: New Tab = local file. The > above FF fix only allows URLs. It doesn't work for every type of local file URI, just some. The bug I had to make it work consistently was closed as WONTFIX (due to security concerns) and my responses ignored. I think people hosting homepages on their local drives are going to be out of luck in the near future because eventually someone will care enough to close off that security hole.
Product: Toolkit → WebExtensions

This bug pretty much stops me from using any extension that does anything with the new-tab.
I want to press ctrl+t and type a url.
But every extension which replaces the new-tab breaks this workflow.

Hopefully my comment will trigger a fresh look at this and make someone go "yeah we can do this!"

I think you are talking about the new Firefox 80 Nightly bug that breaks focus in addressbar for new tab with extension: bug 1652293, bug 1651372.
Both marked as duplicate of bug 1596738 (even though it's not).

Can confirm, new tab override does work, but it really sucks that dev team can't give support to an add on developer that has been around a pretty long time, for something like this, where the focus should not ever be automatically shifting to the address bar upon creation of a new tab ANYHOW, EVER.

It needs to be fixed.

(I am the developer of New Tab Override)

Please note that add-ons like New Tab Override can only implement ugly workarounds to offer a choice at all - and the focus to the addressbar is broken in bad ways for every add-on like this because it is not possible to select the whole URL so that people can immediately start typing. I advocated for a useful API for new tab add-ons for years but so far nothing happened in this area.

The new tab override add-on is slow:

https://addons.mozilla.org/en-US/firefox/addon/new-tab-override/

Currently there's a new tab preference in Firefox, but it's very limited as it only offers the following two choices:

Firefox Home (Default)
Blank

Please add an option to select a URL, in my case I would select https://www.google.com/ as my new tab. In addition please provide an option so the cursor will jump to the first form, in my example this would be the search box.

Thank you.

I just realized I had two new tab add-ons and that was the reason the new tab override add-on was slow. However it would still be great to have in the preferences the option so select a URL and also have an option to have the cursor go to the first form so that no add-on would be needed.

Please can everyone stop commenting on this ticket unless they are proposing an actual implementation that fulfils the original request?

As an add-on author that has been around the Mozilla ecosystem for 16 years I'm aware of other add-ons and how they try to solve the problem and I specifically decided not to go down that route. I stated this in comment #0.

The simple fact is that this type of add-on shouldn't even be necessary because being able to load your homepage in a new tab should be a feature baked into Firefox. That hasn't happened for over a decade, despite it being implemented in every popular tab browsing add-on, and I don't really understand why. Other browsers have this feature, it's not controversial.

Either way, in lieu of a native implementation, we need a better API to make this work properly.

In case you are collecting use cases for this

We are experimenting with extensions that add functionality to the urlbar results, a lot of these will work as plain url suggestions that visit a url when clicked on, this would be simple with browser.tabs.update however we would need it to behave the same way as other url bar suggestions and focus the content

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.