Repository navigation
Cards in-context actions have no context? #5063
|
In the code example named Cards with in context actions there is a Button Dropdown placed in the So, what is the point of placing in-context actions in the Am I missing something? |
Replies: 2 comments
|
You're not missing anything: in that example the Two places in cardDefinition={{
header: item => (
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
<Link href="#" fontSize="heading-m">{item.name}</Link>
<ButtonDropdown
variant="inline-icon"
ariaLabel={`Actions for ${item.name}`}
items={[
{ id: "rm", text: "Delete" },
{ id: "mv", text: "Move" },
]}
onItemClick={({ detail }) => handleAction(detail.id, item)}
/>
</div>
),
sections: [
{ id: "description", header: "Description", content: item => item.description },
],
}}If you'd rather keep the menu next to the "Description" label, move that whole row (label + dropdown) from the section (Checked against |
|
Thanks for your reply. I guess the documentation is a little misleading with actions like "delete" and "move", when that section has no context. |
You're not missing anything: in that example the
ButtonDropdownsits insections[].header, which is a staticReactNode(SectionDefinition.header?: React.ReactNode), and it has noonItemClick, so it's only a visual demo.Two places in
cardDefinitiondo receive the item: the card-levelheader?(item: T)and each section'scontent?(item: T). Put the actions in one of those and the item is in scope for the handler: