-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Activate vomnibar in main/top-level window only (WIP) #1537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Activate vomnibar in main/top-level window only (WIP) #1537
Conversation
This changes vomnibar commands to activate not in the current frame, but in window.top. Consequently, the vomnibar always appears in the same position, and we don't get odd looking vomnibars in small frames. Apart from the better UX, this seems to be the right thing to do. Vomnibar commands apply to tabs (not frames). Currently incomplete: - On exit, the focus is not returned to the frame which originally had the focus. (It's returned to window.top). - The vomnibar can lose the focus and not hide itself for various frame/click combinations.
@smblott-github this causes the Vomnibar to fail when the top level frame has a
I think I think (but haven't tested that) it also might be possible to entangle a port with the Vomnibar frame by doing vomnibarUrl = chrome.runtime.getURL "pages/vomnibar.html"
foundVomnibarFrame = false
for frameWindow in window.top
try # Catch errors from accessing location on cross-origin frames.
if frameWindow.location == vomnibarUrl
foundVomnibarFrame = true
# Set up a port with the window here.
break
unless foundVomnibarFrame
# Code to mitigate there being no such frame. which would avoid the round trip to the background page, by having the vomnibar communicate with the opener frame directly. |
Actually, not. I've been using this as the main test page, and it works fine there.
It turns out to be better/easier than that. The request to open the vomnibar contains the frameId of the originating frame. So the top window knows which frame to focus when it's done. The basics are now functional (efada88). For example, opening the vomnibar in the hangouts sidebar opens a full-window vomnibar, and returns the focus to the sidebar when the vomnibar closes. The approach I took involves extra massaging when the vomnibar closes, but no more messaging than when the vomnibar opened. So no big deal. To do: previously, we hid the vomnibar when the host frame receives the focus. Now, we probably need to hide the vomnibar when any other frame receives the focus. Not sure. Requires more thought. |
Sorry! That was a problem that I ran into before, something must have changed (presumably VIF).
This seems like the most sensible choice. We can easily do this by sending a vomnibar-specific close message in |
It's actually implemented now. I could describe the parts individually, but it'd probably be better if you just review the code (which would be appreciated, if you're able @mrmr1993). Summary:
UX decision:
|
@@ -657,6 +657,19 @@ handleFrameFocused = (request, sender) -> | |||
if frameIdsForTab[tabId]? | |||
frameIdsForTab[tabId] = | |||
[request.frameId, (frameIdsForTab[tabId].filter (id) -> id != request.frameId)...] | |||
console.log frameIdsForTab[tabId] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed
Clean up, and fixes following code review from @mrmr1993.
if request.command.split(".")[0] == "Vomnibar" | ||
if DomUtils.isTopFrame() | ||
# We pass the frameId from request. That's the frame which originated the request, so that's the frame | ||
# which whould receive the focus when the vomnibar closes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo; whould
should be should
.
A reason for not doing this is... If Vimium is disabled for the main/top frame, but enabled for some other frame, then the vomnibar doesn't work. How important is that? Not sure. On the one hand, it's not a common case. On the other, it's pretty broken. Imagine the status quo was vomnibar-in-main-frame and someone proposed getting around this quirk by moving the vomnibar to the host frame (with strange, small vomnibars). Would we buy that? Not sure. Probably not. |
The most logical fix I can think of is to execute |
Update. Having used this for some time, it seems to be robust and work well. To summarise, when the vomnibar opens within frames, we get something like this: With this PR, the vomnibar is always in the main frame, always in the same place, always the same size and always visible.
|
Vomnibar commands are handled in a frame even is isEnabledForUrl is false.
Since the vomnibar now always is initialised and opened the top window (see d673474), there's no longer a need for this to be a Vimium Labs feature.
Another update. With d673474, the Vomnibar now activates in the top/main frame even if Vimium is disabled in that frame. As a consequence, there's no longer a need to consider this as a "Vimium Labs" feature. |
Status:
Issues...
Another issue: |
This LGTM. The 4th case you mention sounds incredibly niche to me.
|
1. Rework event handling to eliminate frame flicker (a la philc#1485). 2. Tidy up logic. Which should make this more robust.
More update. The Vomnibar flicker issue has been fixed. Opinion: We should merge this. It's a big UX win. I'll merge soon, unless there's significant push back. |
This changes vomnibar commands to activate not in the current frame, but in
window.top
. Consequently, the vomnibar always appears in the same position, and we don't get odd looking vomnibars in small frames.Apart from the better UX, this seems to be the right thing to do. Vomnibar commands apply to tabs (not frames).
Currently incomplete:
On exit, the focus is not returned to the frame which originally had the focus. (It's returned to window.top).Fixed.@mrmr1993. What do you think? Have you any ideas how to get the focus back to the original frame?