Skip to content

[EuiContextMenu] renderItem wildcard content #7507

@mdefazio

Description

@mdefazio

Describe the solution you'd like
We would like to have more flexibility on the structure of the context menu when passing in an array of panel objects.

Background

Currently it is possible to pass an array of panel objects that generate the panel structure (alongside being able to build out the context menu by individual components). We would like to be able to have a bit more flexibility with the display of these panels when passing in an array.

cc/ @umbopepato @XavierM @andreadelrio

Expectation

We would like the option to include an option for 'inline' (or whatever makes sense) to a panel which would display this alongside the previous panel, and not a nested panel.

Note: this is just an initial thought, we are absolutely open to better implementation ideas here

An example of this could be the following:

Current setup:

const currentPanels=[
{
 id: 0,
 title: "Fruit",
 items: [
  {
    name: "Bananas",
    onClick: ()=>{...},
  },
  {
    name: "Oranges",
    onClick: ()=>{...},
  },
  {
    name: "Papayas",
    onClick: ()=>{...},
  },
  {
    name: "More fruit",
    icon: “boxesVertical”
    panel: 1,
  },
 ].
},
{
 id: 1,
 title: "More fruit",
 items: [
  {
    name: "Apples",
    onClick: ()=>{...},
  },
  {
    name: "Grapes",
    onClick: ()=>{...},
  },
  {
    name: "Pineapples",
    onClick: ()=>{...},
  },
 ].
}
]

image

Proposal:

const newPanels=[
{
 id: 0,
 title: "Fruit",
 items: [
  {
    name: "Bananas",
    onClick: ()=>{...},
  },
  {
    name: "Oranges",
    onClick: ()=>{...},
  },
  {
    name: "Papayas",
    onClick: ()=>{...},
  },
  {
    name: "More fruit",
    panel: 1,
  },
  {
    name: "Exotic fruit",
    icon: “starFilled”
    panel: 2,
  },
 ].
},
{
 id: 1,
 inline: true, // New option
 items: [
  {
    name: "Apples",
    onClick: ()=>{...},
  },
  {
    name: "Grapes",
    onClick: ()=>{...},
  },
  {
    name: "Pineapples",
    onClick: ()=>{...},
  },
 ].
},
{
 id: 2,
 inline: false, // New option
 items: [
  {
    name: "Durian",
    onClick: ()=>{...},
  },
  {
    name: "Carambola",
    onClick: ()=>{...},
  },
  {
    name: "Jackfruit",
    onClick: ()=>{...},
  },
 ].
}
]

image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions