Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #2708, manually dim toolbar button when disabled
Browse files Browse the repository at this point in the history
On Windows and Linux, WebExtension toolbar buttons are not
automatically dimmed when a button is disabled (bug 1204609).
  • Loading branch information
jaredhirsch committed Apr 19, 2017
1 parent 9a23339 commit b1415f6
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions addon/webextension/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,25 @@ this.main = (function() {
return badDomains.includes(domain);
}

function enableButton(tabId) {
browser.browserAction.enable(tabId);
// We have to manually toggle the icon state, because disabled toolbar
// buttons aren't automatically dimmed for WebExtensions on Windows or
// Linux (bug 1204609).
setIconActive(false, tabId);
}

function disableButton(tabId) {
browser.browserAction.disable(tabId);
setIconActive(true, tabId);
}

browser.tabs.onUpdated.addListener(catcher.watchFunction((id, info, tab) => {
if (info.url && tab.active) {
if (urlEnabled(info.url)) {
browser.browserAction.enable(tab.id);
enableButton(tab.id);
} else if (hasSeenOnboarding) {
browser.browserAction.disable(tab.id);
disableButton(tab.id);
}
}
}, true));
Expand All @@ -190,9 +203,9 @@ this.main = (function() {
return;
}
if (urlEnabled(tab.url)) {
browser.browserAction.enable(tabId);
enableButton(tabId);
} else if (hasSeenOnboarding) {
browser.browserAction.disable(tabId);
disableButton(tabId);
}
}), true);
}));
Expand Down

0 comments on commit b1415f6

Please sign in to comment.