Skip to content

MenuItem label and accelerator should be optional when role is specified #2812

@sindresorhus

Description

@sindresorhus

To reduce boilerplate it would be useful if default values were used for label and accelerator if role were specified.

So instead of:

var template = [
  {
    label: 'Edit',
    submenu: [
      {
        label: 'Undo',
        accelerator: 'CmdOrCtrl+Z',
        role: 'undo'
      },
      {
        label: 'Redo',
        accelerator: 'Shift+CmdOrCtrl+Z',
        role: 'redo'
      }
    ]
  }
];

I could just do:

var template = [
  {
    label: 'Edit',
    submenu: [
      {
        role: 'undo'
      },
      {
        role: 'redo'
      }
    ]
  }
];

submenu should also be optional. Would be useful for the services role.

This would also have the benefit of those menu items being automatically localized for you.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions