Text input loosing focus after switching tabs (Google Docs)
-
@mindplay said in Input focus issue (in Google Docs):
Let me know if there's anything else I can do to help isolate the issue. (I'm a senior web developer, so feel free to get as technical as you need to.)
I am a webdev and IT pro, too.
Unfortunately the Vivaldi developer needs a simpler page where such issue happens, the JavaScript of Google Docs is so much encrypted and obfuscated that it is not debuggable.
Can yo help with a different page where the focus loss can be detected?
-
Can yo help with a different page where the focus loss can be detected?
I haven't seen this happening anywhere else.
I thought I might see a similar issue with something like Figma, since they also use completely custom UI and focus management, but there was no issue there.
Unfortunately the Vivaldi developer needs a simpler page where such issue happens, the JavaScript of Google Docs is so much encrypted and obfuscated that it is not debuggable.
Like anything else on the web.
I have noticed a very small visible difference, when switching between tabs - in Vivaldi, if you watch the cursor in Google Docs very closely, when the tab gets focus, there is very small flickering of the cursor. If you look closely in Chrome, you won't see any flickering of the cursor.
It's extremely subtle - you will likely need to do this many times in both browsers before you notice.
What this might suggest, is an event is being fired twice in rapid succession.
I've occasionally noticed other subtle glitches in Vivaldi's address bar after switching tabs - for example, in a few cases, attempting to create a tab (CTRL+T) and immediately pasting a URL (CTRL+V) the address didn't always have the focus yet, and nothing was pasted. I suspect this might stem from the same focus issue.
I experimented a bit, and I did notice a focus-related difference between Chrome and Vivaldi - so I do have something here you can reproduce:
Open a document in Google Docs and one other tab. (for consistency, a Wikipedia tab like I used.)
Paste the following into DevTools:
["focus", "blur", "focusin", "focusout"].forEach(eventName => { document.documentElement.addEventListener(eventName, e => console.log(eventName, e)) });
This should log every focus event to the console, as long as it's reaching the document root.
Try this in both Vivaldi and Chrome - if you're seeing what I'm seeing, when switching tabs in Chrome, there are no focus events; but in Vivaldi, there are.
Wild guess, but developers tend to get into "patch mode" - if someone was trying to fix a focus related bug, they might have solved it by just firing an extra event. Which would explain the flashing cursor - if it's somehow focusing twice in rapid succession. Google Docs likely isn't expecting that, and likely has some async operations happening in response to these events, which could cause a race somewhere. (so it's getting focus/blur/focus events, and the event handlers end up randomly running in e.g. focus/focus/blur order, if that makes sense?)
You would probably need the Chrome debug protocol monitor and/or a native debugger to pinpoint this issue.
But it's clear there's some sort of difference here, right?
-
Try it with
capture
also:["focus", "blur", "focusin", "focusout"].forEach(eventName => { document.documentElement.addEventListener(eventName, e => console.log(e), { capture: true }) });
There at least 2, sometimes as many as 6 focus related events on the
documentElement
in Vivaldi, whereas in Chrome I'm seeing none. -
I've disabled all extensions just to be on the safe side.
With that last snippet, here's what switching tabs twice looks like on my system:
Again, in Chrome, I'm seeing no output.
Are application (or operating system) level focus events supposed to generate DOM events at all? (does the W3C standard specify?)
There's a
visibilitychange
event, which should tell you about tab/window visibility - I'm not sure if the focus events should be firing or not.It looks like in Chrome they're not, so this might account for the difference in behavior at least.
-
@DoctorG any idea if the devs are reading this forum? this issue seems like a tough one and the information I posted might be helpful. If anyone's reading it.
It's kind of weird how they have no open bug tracker - even just a read-only view of their bug tracker would help avoid duplicate bug reports.
And only tarballs are published? I'm sure they have a point with this approach (saving resources, surfacing important issues by number of times the same issue gets reports) but it doesn't feel very "open source" - and they still have to read bug reports, and probably more duplicates than they'd get if we could check for dupes first.
Either way, I'm back to Chrome for now. I really want to leave, but every Chromium based project somehow turns out to disappoint in one way or another. I mean, if you want to compete with Google on Chrome, you have to at least ship a browser that properly runs Google's apps.
I would have liked to help, but it doesn't seem like help is wanted.
-
@mindplay Be so kind to report the issue to bug tracker.
You can reply to the report mail you received and add more information to help (f.ex. as attachments and text).
Thanks for helping us.
- - - -
Report issue to Vivaldi bug tracker. Once that is done, share the bug number (beginning with VB-). Thanks for helping us making Vivaldi better. -
@DoctorG done.
-
@mindplay Devs very rarely read here.
Please reply to report mail your received and add relevant information (which you wrote here) how you can help the dev and debug the issue!
Your answers by mail will be added automatically to bug tracker so the developer can read them. -
@mindplay VB-94958 "Focus problems in Google Docs" - Confirmed, no dev assigned.
-
When using google docs I've noticed several times that when I switch back to a tab with my open google docs and the cursor blinking and hit ctrl-v to paste some text that it doesn't paste. My current workaround is to hold down shift and the right arrow which selects blank text and then it allows me to paste.
I don't if this is a quirk of my setup but it works as expected in chrome. I have tried it in a new Vivaldi profile and I get the same behavior.
-
@browseruser Hi this is a known issue, see above. Been like this for a long time.
I have merged your topic into this one.
Please try to use the search feature before posting:
https://forum.vivaldi.net/search -
@Pathduck So it's an old issue (I have also noticed for a long time) but just now there is first bug report about it mentioned above VB-(94958 "Focus problems in Google Docs" )?
Or is there another bug report with a more updated status?
-
Seems like it's been a bug since at least 2018 https://forum.vivaldi.net/topic/75404/text-input-loosing-focus-after-switching-tabs-google-docs
Is there really no update on the status of this in almost 5 years?
-
It is not so easy to fix. Google scrambles and encrypts its HTML and JS code. Debugging is a hell with such broken site.
-
I found another site with focus problems.
https://www.thomann.de/dk/index.html
Try putting the cursor in the search input - it just loses focus after a moment.
No doubt this is the same issue - too many focus events, async requests are started, and then resolve in the wrong order.
You don't need to debug Google Docs or this site though - I've provided a simple script that shows what the issue is. There are too many focus events.
Most likely the extra events were introduced in a time before the newer tab events were introduced.
I haven't checked yet, but I wonder if Vivaldi even sends those newer events? If so, apps like Google Docs would most likely respond correctly to those events - and if it doesn't, it probably should send those events instead of the extra focus events.
Check which events Chrome sends for what activities: input focus, tab visibility, window focus - and make sure you send the same events.
This shouldn't be difficult to fix at all, now that you know what the issue is.
-
@mindplay said in Input focus issue (in Google Docs):
https://www.thomann.de/dk/index.html
Try putting the cursor in the search input - it just loses focus after a moment.No issue with the search field here for me, testing in a clean profile of 5.7 Stable, Win10. A "popup" appears where I can search. Maybe the content blocker is interfering?
I've provided a simple script that shows what the issue is.
Where it that script?
-
@Pathduck said in Input focus issue (in Google Docs):
I've provided a simple script that shows what the issue is.
Where it that script?
Pretty sure he provided the short script in https://forum.vivaldi.net/post/641001
-
Yeah, scroll up for the script snippet + explanation.
Regarding thomann.de - this might actually be an issue with Vivaldi for Android only. I tap the search input, it gets the focus for a second, and then the on-screen keyboard disappears. Could someone verify that, please?
(on my Windows desktop, I've reverted to Chrome because of the focus issue - I'm still using Vivaldi on Android though, because it's generally just better, and I don't use Google docs on my mobile.)
I assumed it's the same issue, since it's focus related, but I suppose these might be different issues.
-
@mindplay Yes can confirm this is a problem on Vivaldi for android but works fine on android chrome. Probably a separate issue for https://forum.vivaldi.net/category/147/vivaldi-for-android
-
@mindplay said in Input focus issue (in Google Docs):
this might actually be an issue with Vivaldi for Android only
Then please ask at https://forum.vivaldi.net/category/147/vivaldi-for-android
I guess such focus issues on Android and Windows are different.