ContextualMenu: Factor out a Menu component
The <ContextualMenu> class has more responsibilities than it should. In addition to taking a command list and rendering a callout, it also handles the interaction with the command list and rendering of menu items.
Ideally, <ContextualMenu> should just be a compositional component that wraps a <Callout> around a <Menu> component. The <Menu> component would render a veritically-navigable list of commands, handling keyboard focus and selection, and would provide a callback with regard to how to render child menus.
export default class Callout extends ___ {
public render() {
...
return (
<Callout
...
>
<Menu
...
renderChildMenu={
(items: IMenuItems) =>
(
<ContextualMenu
items={ items }
/>
)
/>
</Callout>
)
}
}
The idea is that <ContextualMenu> would now just delegate all menu item rendering to a <Menu> component, but tell the <Menu> that child menu item lists need to render using another <ContextualMenu> component.
If we have a <Menu> component, it could be re-used in the <LeftNav> component, ensuring that all the latest accessibility enhancements and ability to render different menu item templates are shared.
Issue got closed in Nov. Updating the status.