Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Added headerButtonProps prop to PivotItem to allow passing native props (data-* & aria-*) to the header/link/CommandButton element. Also depricated linkText and added headerText for semantic purposes.",
"type": "minor"
}
],
"packageName": "office-ui-fabric-react",
"email": "v-brgarl@microsoft.com"
}
12 changes: 7 additions & 5 deletions packages/office-ui-fabric-react/src/components/Pivot/Pivot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class Pivot extends BaseComponent<IPivotProps, IPivotState> {
}

private _renderPivotLink = (link: IPivotItemProps): JSX.Element => {
const { itemKey } = link;
const { itemKey, headerButtonProps } = link;
const tabId = this._keyToTabIds[itemKey as string];
const { onRenderItemLink } = link;
let linkContent: JSX.Element | null;
Expand All @@ -130,6 +130,7 @@ export class Pivot extends BaseComponent<IPivotProps, IPivotState> {

return (
<CommandButton
{ ...headerButtonProps }
id={ tabId }
key={ itemKey }
className={ css(
Expand All @@ -144,15 +145,15 @@ export class Pivot extends BaseComponent<IPivotProps, IPivotState> {
ariaLabel={ link.ariaLabel }
role='tab'
aria-selected={ this.state.selectedKey === itemKey }
name={ link.linkText }
name={ link.headerText }
>
{ linkContent }
</CommandButton>
);
}

private _renderLinkContent = (link: IPivotItemProps): JSX.Element => {
const { itemCount, itemIcon, linkText } = link;
const { itemCount, itemIcon, headerText } = link;

return (
<span className={ css('ms-Pivot-link-content') }>
Expand All @@ -161,7 +162,7 @@ export class Pivot extends BaseComponent<IPivotProps, IPivotState> {
<Icon iconName={ itemIcon } />
</span>
) }
{ linkText !== undefined && <span className={ css('ms-Pivot-text', styles.text) }> { link.linkText }</span> }
{ headerText !== undefined && <span className={ css('ms-Pivot-text', styles.text) }> { link.headerText }</span> }
{ itemCount !== undefined && <span className={ css('ms-Pivot-count', styles.count) } > ({ itemCount })</span> }
</span>
);
Expand Down Expand Up @@ -204,7 +205,8 @@ export class Pivot extends BaseComponent<IPivotProps, IPivotState> {
const itemKey = pivotItem.props.itemKey || index.toString();

links.push({
linkText: pivotItem.props.linkText,
headerText: pivotItem.props.headerText || pivotItem.props.linkText,
headerButtonProps: pivotItem.props.headerButtonProps,
ariaLabel: pivotItem.props.ariaLabel,
itemKey: itemKey,
itemCount: pivotItem.props.itemCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@ export interface IPivotItemProps extends React.HTMLAttributes<HTMLDivElement> {
componentRef?: () => void;

/**
* The text displayed of each pivot link.
* The text displayed of each pivot link - renaming to 'headerText'.
* @deprecated
*/
linkText?: string;

/**
* The text displayed of each pivot link.
*/
headerText?: string;

/**
* Props for the header command button supporting native props - data-* and aria-* - for each pivot header/link element
*/
headerButtonProps?: { [key: string]: string | number | boolean };

/**
* An required key to uniquely identify a pivot item.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ export class PivotBasicExample extends React.Component<any, any> {
return (
<div>
<Pivot>
<PivotItem linkText='My Files'>
<PivotItem
headerText='My Files'
linkText='I am deprecated. "headerText" overwrites me'
headerButtonProps={ {
'data-order': 1,
'data-title': 'My Files Title'
} }
>
<Label className={ exampleStyles.exampleLabel }>Pivot #1</Label>
</PivotItem>
<PivotItem linkText='Recent'>
Expand Down