Skip to content
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

Clicking on 1st subitem in Tray menu does not work on Linux #9495

Closed
ventsislav-georgiev opened this issue May 16, 2017 · 5 comments
Closed

Comments

@ventsislav-georgiev
Copy link

  • Electron version: 1.6.8
  • Operating system: Ubuntu 16.04

Expected behavior

Submenu items in Tray menu should properly raise click event when clicked.

Actual behavior

The 1st submenu item in tray menu cannot be clicked when in the parent menu hierarchy there is a disabled item.

How to reproduce

  let template = [{
    label: "1 item",
    enabled: false
  }, {
    label: "2 item",
    submenu: [{
      label: "1 subitem",
      click: () => console.log("1 subitem click")
    }, {
      label: "2 subitem",
      click: () => console.log("2 subitem click")
    }]
  }];

  tray = new Tray(nativeImage.createFromDataURL("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAB4UlEQVQ4jbXVO2gUURTG8d/MLiERZE0kRGFFIZ2ExCapLExlLI1VbGzFylj4iLVaWCjWFlZaCDYWJiBCsNMqugqB+CBEg0hMFtE83IfFzOpmmOgsxq+753znf+6FyznBj/vDtlAnxnAM/diDDSxgDo9wD8tpxUEKuB3jOI9dW3WNtYLruIHV5kSYMB7Ac1zNABV7ruBZXJsKLuIp+jIAk+qLa4tJcDseNBK5oQn5E4+F/adbgRdjRkcz+CwGG45g3zBBKCweafXmgzFLiC5cbM7WSrfVl2fVXt9pFQwX0JUXfanCJvD8E8HCtHp1Iwp0dAvCXHReLwt2HyTXpr70ispaElzAWB5Hk5n88C129Kh/nlGdHv99Lr8BQaE3Mq59UZ0+p/51PokYCXEo6xuDQq9g534q8Zdt7xIOnEmzDoToyQpW+a46dUrl4aj6t8WoWXfqvXpCrGfl1stvI2B1naVSFMy1pXpDLGa+ca3a1KX2J+enELOZwdk1E2LqP4AnQ9HoK28jtIx7jbF5STTRtkMTuNaYFTfxchugpZj1awitYhQf/wH6Acdj1qZ5PIfDcddWVYpr5xqB5AZ5hyFcFq2dv2kl9g7hfXMibec11ImTGBEt071xfBEvMIm7tlimPwG5j4M02bHWtgAAAABJRU5ErkJggg=="));
  tray.setContextMenu(Menu.buildFromTemplate(template));

Click on the "1 subitem" and see that there is nothing logged.

@dregenor
Copy link

same problem

@dregenor
Copy link

dregenor commented May 26, 2017

looks like this problem in chromium implementation

get menu item id
there id is "Number in the list" (for 1st item in submenu this method return 0)
and
check if this menu item enabled

there menu_model_ is root menu model not submenu

so i can add one more case to @ventsislav-georgiev

let template = [{
    label: "1 item",
    enabled: true
  },
 {
    label: "2 item",
    enabled: false
  },
 {
    label: "submenu",
    submenu: [{
      label: "1 subitem",
      click: () => console.log("1 subitem click")
    }, {
      label: "2 subitem",
      click: () => console.log("2 subitem click")
    }]
  }];

  tray = new Tray(nativeImage.createFromDataURL("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAB4UlEQVQ4jbXVO2gUURTG8d/MLiERZE0kRGFFIZ2ExCapLExlLI1VbGzFylj4iLVaWCjWFlZaCDYWJiBCsNMqugqB+CBEg0hMFtE83IfFzOpmmOgsxq+753znf+6FyznBj/vDtlAnxnAM/diDDSxgDo9wD8tpxUEKuB3jOI9dW3WNtYLruIHV5kSYMB7Ac1zNABV7ruBZXJsKLuIp+jIAk+qLa4tJcDseNBK5oQn5E4+F/adbgRdjRkcz+CwGG45g3zBBKCweafXmgzFLiC5cbM7WSrfVl2fVXt9pFQwX0JUXfanCJvD8E8HCtHp1Iwp0dAvCXHReLwt2HyTXpr70ispaElzAWB5Hk5n88C129Kh/nlGdHv99Lr8BQaE3Mq59UZ0+p/51PokYCXEo6xuDQq9g534q8Zdt7xIOnEmzDoToyQpW+a46dUrl4aj6t8WoWXfqvXpCrGfl1stvI2B1naVSFMy1pXpDLGa+ca3a1KX2J+enELOZwdk1E2LqP4AnQ9HoK28jtIx7jbF5STTRtkMTuNaYFTfxchugpZj1awitYhQf/wH6Acdj1qZ5PIfDcddWVYpr5xqB5AZ5hyFcFq2dv2kl9g7hfXMibec11ImTGBEt071xfBEvMIm7tlimPwG5j4M02bHWtgAAAABJRU5ErkJggg=="));
  tray.setContextMenu(Menu.buildFromTemplate(template));

in this case second subitem will be not clickable, and first clickable.
i was checked this issue on electron 1.4.16 and this issue reproducible.

@dregenor
Copy link

dregenor commented Jun 14, 2017

@kevinsawicki can you review this PR and merge this?
electron/libchromiumcontent#310 - for electron 1.6.x
electron/libchromiumcontent#314 - for electron 1.7.x

@dregenor
Copy link

dregenor commented Jul 4, 2017

@kevinsawicki can i do something, to speed up merging of this PR?

@kevinsawicki
Copy link
Contributor

can i do something, to speed up merging of this PR?

Thanks for fixing this @dregenor, apologies for the delay merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants