I hope this is the right place to file documentation issues -- if not, let me know and I'd be happy to edit this issue to follow the bug report template.
The documentation for <CommandBar> is rather opaque regarding the structure of ICommandBarItemProps. Since the items list is arguably the most important part of the <CommandBar> API, improving this documentation would be a big DX win.
Currently, neither of the examples describe how the items array should be structured. Instead, they are thin wrappers around the <CommandBar> component. The first example in particular is practically the identity component:
public render(): JSX.Element {
const { items, overflowItems, farItems } = this.props;
return (
<div>
<CommandBar
items={items}
overflowItems={overflowItems}
farItems={farItems}
ariaLabel={'Use left and right arrow keys to navigate between commands'}
/>
</div>
);
}
The second example, "CommandBar custom buttons and overflow menu," is also unclear because:
$ITEM_NAME hovered whenever the user mouses over a button. This behavior is invisible, unless the user happens to have the console open.Suggested changes:
items prop as a full array/object literal.alert() dialog.After reading the examples, I was still unsure how to actually use the <CommandBar>, so I looked at the documentation. Sure enough, the first required prop was items: ICommandBarItemProps[].
However, the interface table for ICommandBarItemProps only lists six optional members. It's never actually stated that ICommandBarItemProps inherits from IContextualMenuItem, which is documented much further down the page with no context, despite being one of the most important <CommandBar> APIs. I had to grep the source to figure out the relationship.
Suggested changes:
ICommandBarItemProps table. If inlining would be unfaithful to the object-oriented paradigm, then the two sections should appear back-to-back for ease of use.The parser automatically generates this documentation from each component's types.ts file and shows types in the order they are defined. However, it does not seem to expand or document interface inheritance, which is why that detail is not shown.
I see this issue having two parts:
Similar to #5937, if you'd like to submit a PR for any of these, it'd be more than welcome. Thanks!
Opened up a separate issue to capture the work needed for improved implementation section #6015. Will close this issue up with specific work to clarify CommandBar examples and interface comments.
Most helpful comment
The parser automatically generates this documentation from each component's
types.tsfile and shows types in the order they are defined. However, it does not seem to expand or document interface inheritance, which is why that detail is not shown.I see this issue having two parts:
Similar to #5937, if you'd like to submit a PR for any of these, it'd be more than welcome. Thanks!