Closed Bug 1295400 Opened 8 years ago Closed 6 years ago

Need an API to focus on the awesomebar or tab's content

Categories

(WebExtensions :: Frontend, defect, P5)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: shinglyu, Unassigned)

References

Details

(Whiteboard: [design-decision-denied]triaged)

Although Chrome doesn't have it. It's still useful to have an API that can let me programatically focus on the awesomebar. When writing add-ons that handles tabs, its pretty common to focus the awesomebar so the user can quickly navigate to an URL or search.
Whiteboard: [design-decision-needed]
Summary: Need an API to focus on the asesomebar → Need an API to focus on the awesomebar
Component: WebExtensions → WebExtensions: Frontend
Priority: -- → P5
Whiteboard: [design-decision-needed] → [design-decision-needed]triaged
Flags: needinfo?(aswan)
We discussed this this morning and there was general agreement that this sounds useful in principle but a lot of concern about how exactly this would work.  If this is done as a simple method to change the focus, it could very easily happen at a time that just confuses the user, and there's also a good chance that scripts in web content setting focus would fight and race against extensions trying to set focus, creating an uneven and inconsistent experience.
Shing Lyu, can you explain more about a specific case where you would like to use this feature and perhaps suggest what the API might look like?
Flags: needinfo?(aswan)
I'm developing a web-ext-based vim control add-on, which enables user to control Firefox in vim key bindings. What I want is when I run `:open` I can focus and select all in the awesome bar, so the user can open a new URL. I also need this in the open new tab case, so user can type the URL directly after the new tab was open. 

I don't have a clear idea about what the API should be, but maybe expose a way I can get the awesomebar with querySelector or something. Like:

```
chrome.querySelector('.awesomebar').focus()
```
In order to workaround this, I wrote part of my add-on in jetpack: https://github.com/shinglyu/QuantumVim/blob/master/jetpack/index.js#L14 

But then my user has to install two add-ons (one in web-ext and one in jetpack) to get the full functionality, which is not the best experience.
VimFx[1] also wants this.

VimFx has the ability to focus the location bar today, and I can't remember any focus race condition problems.

People often make feature requests to the Vimium[2] extension for Chrome, asking for a command to focus the location bar, but the maintainers can't do more than saying that it is not possible to implement.

(Actually, I think that making it possible to trigger every standard Firefox keyboard shortcut action would be useful. I'm thinking something like chrome.keyboardActions.focusLocationBar(), where chrome.keyboardAction is an object with methods for every keyboard shortcut action. See also bug 1215061; I plan on writing a WebExtension experiment there soon, that might also include this kind-of-related issue/feature).

[1]: https://github.com/akhodakivskiy/VimFx/
[2]: https://github.com/philc/vimium/
(In reply to Simon Lydell from comment #5)
> (Actually, I think that making it possible to trigger every standard Firefox
> keyboard shortcut action would be useful. 

Agree!
We discussed about this issue during the last "WebExtensions APIs Triage" meeting, 
unfortunately we didn't reach a reasonable agreement on it, and so this is currently design-decision-denied (at least in this form).

It worth to mention that a subset of what the original request described in Comment 1 has been provided by Bug 1295072:

- when a new empty tab is opened by a webextension, the awesome bar is automatically focused.
Whiteboard: [design-decision-needed]triaged → [design-decision-denied]triaged
@andym and the Mozilla team

Since FF is going all-WebExtensions very soon. We need a clean way to allow for the most trivial and natural thing users 
(including the most casual users) want to do:

Open a new tab and have their favorite search engine/website (Google/Yahoo/Bing/DuckDuckGo etc.) immediately open, cleanly, in a visually appealing way with no strange flickering, redirects, session or browser history pollution, title bar anomalies, address bar jitter, etc. and most importantly - *have the input focus on the page to allow people to use their browser normally* like they used to and want to.

For now we have Tab Mix Plus (unless we use Nightly). Soon, it seems, we'll go straight to a janky Chrome-like experience with extensions going through hoops (and frequently failing) to come up miracle hacks to overcome the lack of basic extension functionality.

I cannot overemphasize how important I think this is. As I see it, this is as important as, or even more than, Servo, Photon and all the other new enhancements and bells and whistles. Please considering listening to your users.

(BTW I'm a huge Firefox fan and been using it continuously since 2004.. I'm working on several basic extensions now on my free time just to try help you guys get out of this mess)

(I've posted the related bug 1385595 with an API suggestion but it was closed and marked as duplicate of this one)
See Also: → 1389003
Summary: Need an API to focus on the awesomebar → Need an API to focus on the awesomebar or tab's content
I am the developer of New Tab Override and I also need this enhancement. Please see bug 1389003 (a duplicate bug I opened a few moments ago) where I described why this is an IMPORTANT feature for my add-on (with more than 100,000 users…).

(Thank you, YF (Yang), for pointing me to this bugzilla ticket)
As discussed on IRC re: 1403295, we think it may be possible to accept this API.

Security concerns:

 - Ability to paste into the bar to access pages that webextensions are not allowed to open on their own

Some usability concerns:

 - Webextensions should only modify the firefox UI in ways users expect
 - Different extensions trying to focus/unfocus the bar at the same time

Possible mitigations are:

 - This function may only be called in response to event handlers
 - Element may not be pasted into
 - Change restricted pages such that nothing bad happens when they're visited or passed get parameters or anchors

An implementation is available as part of https://github.com/Koushien/keyboard-shortcut-api

    https://github.com/Koushien/keyboard-shortcut-api/blob/d3163590991cb7d5fcee8308f3cec5eefaa5a542/api.js#L398

When a keyboard api (1215061) is supported, this functions mirror, focusContent, will also be very useful.
Flags: needinfo?(aswan)
Closing all open bugs with the [design-decision-denied] whiteboard flag.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
Product: Toolkit → WebExtensions

I don't remember what the needinfo was for 2 years ago, please follow up with :Fallen if there's still interest in this.

Flags: needinfo?(andrew.swan)
You need to log in before you can comment on or make changes to this bug.