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

[Bug]: Menu.getApplicationMenu() returns menu with invalid roles #42497

Open
3 tasks done
takuyahara opened this issue Jun 14, 2024 · 0 comments
Open
3 tasks done

[Bug]: Menu.getApplicationMenu() returns menu with invalid roles #42497

takuyahara opened this issue Jun 14, 2024 · 0 comments

Comments

@takuyahara
Copy link

Preflight Checklist

Electron Version

31.0.1

What operating system are you using?

macOS

Operating System Version

macOS Sonoma 14.5

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

No response

Expected Behavior

Menu.getApplicationMenu() returns menu with valid roles.

Actual Behavior

As titled. Since this is TypeScript's type issue I created a Stackblitz project here for a reproduction.

https://stackblitz.com/~/github.com/takuyahara/electron-menu-issue?file=src/main.ts:L25

image

console.log in L17 results the following; every role is entirely lower case if exists.
[
  {
    "role": "appmenu",
    "subItems": [
      {
        "role": "about"
      },
      {
        "role": null
      },
      {
        "role": "services"
      },
      {
        "role": null
      },
      {
        "role": "hide"
      },
      {
        "role": "hideothers"
      },
      {
        "role": "unhide"
      },
      {
        "role": null
      },
      {
        "role": "quit"
      }
    ]
  },
  {
    "role": "filemenu",
    "subItems": [
      {
        "role": "close"
      }
    ]
  },
  {
    "role": "editmenu",
    "subItems": [
      {
        "role": "undo"
      },
      {
        "role": "redo"
      },
      {
        "role": null
      },
      {
        "role": "cut"
      },
      {
        "role": "copy"
      },
      {
        "role": "paste"
      },
      {
        "role": "pasteandmatchstyle"
      },
      {
        "role": "delete"
      },
      {
        "role": "selectall"
      },
      {
        "role": null
      },
      {
        "role": null
      },
      {
        "role": null
      }
    ]
  },
  {
    "role": "viewmenu",
    "subItems": [
      {
        "role": "reload"
      },
      {
        "role": "forcereload"
      },
      {
        "role": "toggledevtools"
      },
      {
        "role": null
      },
      {
        "role": "resetzoom"
      },
      {
        "role": "zoomin"
      },
      {
        "role": "zoomout"
      },
      {
        "role": null
      },
      {
        "role": "togglefullscreen"
      }
    ]
  },
  {
    "role": "windowmenu",
    "subItems": [
      {
        "role": "minimize"
      },
      {
        "role": "zoom"
      },
      {
        "role": null
      },
      {
        "role": "front"
      }
    ]
  },
  {
    "role": "help",
    "subItems": [
      {
        "role": null
      },
      {
        "role": null
      },
      {
        "role": null
      },
      {
        "role": null
      }
    ]
  }
]

But comparing role with a lower cased string causes the following error.

This comparison appears to be unintentional because the types '"undo" | "redo" | "cut" | "copy" | "paste" | "pasteAndMatchStyle" | "delete" | "selectAll" | "reload" | "forceReload" | "toggleDevTools" | "resetZoom" | "zoomIn" | "zoomOut" | ... 29 more ... | "windowMenu"' and '"viewmenu"' have no overlap.

As defined in electron.d.ts role must be camel cased, so the returned menu by Menu.getApplicationMenu() seems wrong.

image

Testcase Gist URL

No response

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👍 Does Not Block Stable
Status: 🛑 Blocks Stable
Development

No branches or pull requests

4 participants