Skip to content

Commit

Permalink
Ensure icon & context menu are up to date on window focus change
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jul 26, 2019
1 parent 869c63f commit aaee898
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions platform/chromium/vapi-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,27 @@ vAPI.Tabs = class {
this.onUpdated(tabId, changeInfo, tab);
});

browser.tabs.onActivated.addListener((tabId, details) => {
this.onActivated(tabId, details);
browser.tabs.onActivated.addListener(details => {
this.onActivated(details);
});

// https://github.com/uBlockOrigin/uBlock-issues/issues/151
// https://github.com/uBlockOrigin/uBlock-issues/issues/680#issuecomment-515215220
if ( browser.windows instanceof Object ) {
browser.windows.onFocusChanged.addListener(windowId => {
if ( windowId === browser.windows.WINDOW_ID_NONE ) { return; }
browser.tabs.query({ active: true, windowId }, tabs => {
if ( Array.isArray(tabs) === false ) { return; }
if ( tabs.length === 0 ) { return; }
const tab = tabs[0];
this.onActivated({
tabId: tab.id,
windowId: tab.windowId,
});
});
});
}

browser.tabs.onRemoved.addListener((tabId, details) => {
this.onClosed(tabId, details);
});
Expand Down

8 comments on commit aaee898

@uBlock-user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any change in the feedback I posted in uBlockOrigin/uBlock-issues#680 (comment) with this commit, I can still reproduce that.

@gorhill
Copy link
Owner Author

@gorhill gorhill commented on aaee898 Jul 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The toolbar icon is properly updated whenever I bring forth the tab. It won't update until you bring forth the tab, because I do not want uBO to force-update the icon until the tab is activated, because someone could have hundreds of tabs and I figure that would cause noticeable performance issue.

@uBlock-user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks that will work but you will have click on the tab to make it active even if it's active after closing the new window which we opened to remove the rule in Whitelist tab.

@gorhill
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need to click the tab if it's already active when closing the window, I just tried it and the icon was updated.

@uBlock-user
Copy link
Contributor

@uBlock-user uBlock-user commented on aaee898 Jul 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the popup panel open when the tab got switched back to the domain on which you whitelisted ?

What you said works only if the popup panel is closed and the popup panel remains open/won't close automatically when you open dashboard(which I know is new behaviour for a bug you fixed) in a new window.

@uBlock-user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the popup panel being open --

Untitled

@gorhill
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The popup panel closes as soon as the new window opens -- normal browser behavior.

@uBlock-user
Copy link
Contributor

@uBlock-user uBlock-user commented on aaee898 Jul 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The popup panel closes as soon as the new window opens

Click on the extension icon and open the popup panel.
Right click on Dashboard icon and select Open link in a new window.

This is what happens --

As you can see the popup panel remains open.

Addendum: This behaviour is Chromium specific too. Popup panel does get closed automatically on Firefox.

Please sign in to comment.