Merge pull request #190 from jonathanKingston/fix-file-menu-mac

Fixing osx menus. Also refresh context and file menus when a custom c…
This commit is contained in:
luke crouch 2017-02-15 20:33:44 -06:00 committed by GitHub
commit 8ba745e1a7

View file

@ -1027,26 +1027,27 @@ ContainerWindow.prototype = {
// Generic menu configuration. // Generic menu configuration.
_configureMenu(menuId, excludedContainerCb, clickCb, arrayName) { _configureMenu(menuId, excludedContainerCb, clickCb, arrayName) {
const menu = this._window.document.getElementById(menuId); const menu = this._window.document.getElementById(menuId);
this._disableElement(menu, arrayName);
if (!this._disableElement(menu, arrayName)) { if (!this._disableElement(menu, arrayName)) {
return Promise.resolve(null); // Delete stale menu that isn't native elements
while (menu.firstChild) {
menu.removeChild(menu.firstChild);
}
} }
const menupopup = this._window.document.createElementNS(XUL_NS, "menupopup"); const menupopup = this._window.document.createElementNS(XUL_NS, "menupopup");
menu.appendChild(menupopup); menu.appendChild(menupopup);
menupopup.addEventListener("command", clickCb); menupopup.addEventListener("command", clickCb);
menupopup.addEventListener("popupshowing", e => { return this._createMenu(menupopup, excludedContainerCb);
return this._createMenu(e, excludedContainerCb);
});
return Promise.resolve(null);
}, },
_createMenu(event, excludedContainerCb) { _createMenu(target, excludedContainerCb) {
while (event.target.hasChildNodes()) { while (target.hasChildNodes()) {
event.target.removeChild(event.target.firstChild); target.removeChild(target.firstChild);
} }
return new Promise((resolve, reject) => {
ContainerService.queryIdentities().then(identities => { ContainerService.queryIdentities().then(identities => {
const fragment = this._window.document.createDocumentFragment(); const fragment = this._window.document.createDocumentFragment();
@ -1079,10 +1080,10 @@ ContainerWindow.prototype = {
fragment.appendChild(menuitem); fragment.appendChild(menuitem);
}); });
event.target.appendChild(fragment); target.appendChild(fragment);
}).catch(() => {}); resolve();
}).catch(() => {reject();});
return true; });
}, },
// This timer is used to hide the panel auto-magically if it's not used in // This timer is used to hide the panel auto-magically if it's not used in