Disable autofocus or blur on ESC
-
Despite having the setting Tabs > Tabs Handling > Focus Page Content on New Tab disabled, some pages will still autofocus an input on their page. Google being an obvious one, the Vivaldi settings page perhaps a less obvious one.
I imagine this is something the websites are doing themselves and the setting is there to force focus on a page if they don't.I'm looking for a way to either disable the autofocus entirely or an option to blur the page focus with ESC. Is this something that can be done in Vivaldi itself or should this be done with an extension?
PS. the settings page is probably the worst offender in this case as it seems impossible to blur any focus. What's going on here?
-
@Kesch Well, the Vivaldi Settings page is supposed to focus when opening, so no issue there and that won't be changed. I don't see why anyone would open Settings, and then expect input focus to be on the url field...
The New Tab setting only applies to actual new tabs i.e. clicking the
+
or using Ctrl+T for instance. It has no relevance to opening new tabs with websites, in that case the website will always be focused.Autofocus is a HTML attribute set by the website on input elements.
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus
The browser is required to follow the HTML standard and there is no setting to change this.Here's a test case:
https://pathduck.github.io/test/focus/
The second input has the Autofocus attribute set.You'd have to use an extension or a user script to change how webpages behave. Here's one I found with a quick search:
https://superuser.com/questions/694125/how-to-disable-autofocus-on-input-fields-in-chromeMost extensions and user-scripts seem to want the opposite - forcing input focus on certain fields when the webpage does not focus it automatically.
In addition, Vivaldi is AFAIK the only browser that allows you to press ESC to remove focus from an input. In other browsers you have to to press Tab to un-focus.
Google's search field in a special case, it's doing stuff to force the input focus on the field. It's not a regular HTML input field.
-
@Pathduck Thanks for the detailed reply.
Perhaps trying to disable autofocus is not the way to go about it.In addition, Vivaldi is AFAIK the only browser that allows you to press ESC to remove focus from an input. In other browsers you have to to press Tab to un-focus.
I guess I never realised this considering I've been using Vivaldi for years now. In your github test I can indeed confirm this works. Maybe I was already using it without thinking about it.
Google and the settings page both seem to be doing stuff to trap the browsers focus. No way around that I guess. Thanks again.
-
@Kesch I did some searching earlier, and found this userscript:
https://superuser.com/a/694138/Testing that in Tampermonkey it seems to work fine, at least for standard input fields (i.e. not Google's hack).
I'm no JS expert but I'm guessing the important bit is:
document.activeElement.blur();
I removed everything but that one line from the code and that seems to even nuke Google's search field focusAlthough doing that might have other unexpected effects on other sites.
Google and the settings page both seem to be doing stuff to trap the browsers focus. No way around that I guess. Thanks again.
The Settings page is part of the Vivaldi UI, not a web page. So it works as it's supposed to.
Although there is a small bug there in that the search input field seems to steal focus when the tab is changed, which is slightly annoying and it didn't do that before the recent versions, so I might report a bug on that one day.
-
Although there is a small bug there in that the search input field seems to steal focus when the tab is changed, which is slightly annoying and it didn't do that before the recent versions, so I might report a bug on that one day.
This might be what is bothering me. I was messing around with the new dashboard and got similar behavior there as well. See attached gif where I can't use escape to blur the note widget but after pressing escape on the address bar the first link on the dashboard will highlight. If there's no bookmark widget here, it will focus the settings icon.
If this is not how it used to work would it be helpful to create a bug report or perhaps a feature request if this is new?
-
@Kesch I don't know, I don't use the widgets.
The Widgets are not a web page, they are still part of Vivaldi's UI.
You can't expect parts of the UI to act like a rendered web page would.
Well, the Vivaldi UI is a "web page" in itself but that's another discussionBut if you feel something is worth a bug report, feel free to make one.
I guess it would be something like:
"Notes widget does not unfocus on pressing ESC"
The widgets are new in 7.0 so will probably be improved over time in any case.I have reported the Settings search field stealing focus as:
VB-111111 Settings search field steals focus after tab switch with Settings in tab
-
@Kesch Did the userscript I posted a link to work to fix your input field issues on web pages?
-
@Pathduck Thanks for reporting the bug. I'll keep my eye on it and further improvements of the dashboard.
Did the userscript I posted a link to work to fix your input field issues on web pages?
I didn't actually try the userscript but I'm sure it would work for web pages. I might write an small extension for it if I feel like I need it but like you said, most web pages will already allow esc to un-focus the active element which is enough for now.