Skip to content

Commit

Permalink
fix: remove scrollbar from contextual sub-menus #1887
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok committed Apr 6, 2023
1 parent bf854cd commit 83ebe67
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions ui/src/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,28 @@ const
alignItems: 'center'
}
},
menuStyles: any = { // TODO: fix type
subComponentStyles: {
menuItem: {
icon: { lineHeight: 'initial' },
subMenuIcon: { lineHeight: 'initial', height: 'auto' }
},
}
},
getItemProps = (commands: Command[]) => {
return commands.map(({ name, label, caption, icon, value, data, items }) => // TODO: add items
({ key: name, text: label, title: caption, iconProps: { iconName: icon }, data: value ?? data, disabled, onClick: handleOnClick(name, value), subMenuProps: items ? { items: getItemProps(items) } : undefined })
)
return commands.map(({ name, label, caption, icon, value, data, items }) =>
({
key: name,
text: label,
title: caption,
iconProps: { iconName: icon },
data: value ?? data, disabled,
onClick: handleOnClick(name, value),
subMenuProps: items
? { items: getItemProps(items) as Fluent.IContextualMenuItem[], styles: menuStyles } as Fluent.IContextualMenuProps
: undefined
})
) as Fluent.IContextualMenuItem[]
},
menuItems = commands
? getItemProps(commands)
Expand All @@ -168,8 +186,7 @@ const
iconProps: { iconName: icon },
menuProps: menuItems ? {
items: menuItems,
// TODO: Add style for sub-items with an icon.
styles: { subComponentStyles: { menuItem: { icon: { lineHeight: 'initial' }, subMenuIcon: { lineHeight: 'initial', height: 'auto' } } } }
styles: menuStyles
} : undefined,
split: !!menuItems
}
Expand Down

0 comments on commit 83ebe67

Please sign in to comment.