Skip to content

Commit

Permalink
fix(Pivot): remove toolbar role, pass naming attrs through (#20317)
Browse files Browse the repository at this point in the history
* remove wayward toolbar semantic from tabs

* snapshots

* Change files
  • Loading branch information
smhigley authored Oct 26, 2021
1 parent 9e5944c commit 6f07e52
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 77 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Remove incorrect toolbar role from Pivot and pass accname attributes to the tablist",
"packageName": "@fluentui/react",
"email": "sarah.higley@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ exports[`Component Examples renders Keytips.Basic.Example.tsx correctly 1`] = `
<p>
For Pivots, keytips will first show for each of the pivots. After selecting a pivot, the Keytips for its content are shown.
</p>
<div
role="toolbar"
>
<div>
<div
className=
ms-FocusZone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,9 @@ exports[`Component Examples renders Pivot.AlwaysRender.Example.tsx correctly 1`]
</button>
</div>
</div>
<div
aria-label="Separately Rendered Content Pivot Example"
role="toolbar"
>
<div>
<div
aria-label="Separately Rendered Content Pivot Example"
className=
ms-FocusZone
ms-Pivot
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Component Examples renders Pivot.Basic.Example.tsx correctly 1`] = `
<div
aria-label="Basic Pivot Example"
role="toolbar"
>
<div>
<div
aria-label="Basic Pivot Example"
className=
ms-FocusZone
ms-Pivot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

exports[`Component Examples renders Pivot.IconCount.Example.tsx correctly 1`] = `
<div>
<div
aria-label="Count and Icon Pivot Example"
role="toolbar"
>
<div>
<div
aria-label="Count and Icon Pivot Example"
className=
ms-FocusZone
ms-Pivot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

exports[`Component Examples renders Pivot.Large.Example.tsx correctly 1`] = `
<div>
<div
aria-label="Large Link Size Pivot Example"
role="toolbar"
>
<div>
<div
aria-label="Large Link Size Pivot Example"
className=
ms-FocusZone
ms-Pivot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ exports[`Component Examples renders Pivot.OnChange.Example.tsx correctly 1`] = `
>
Last onLinkClick from:
</label>
<div
aria-label="OnChange Pivot Example"
role="toolbar"
>
<div>
<div
aria-label="OnChange Pivot Example"
className=
ms-FocusZone
ms-Pivot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,9 @@ Array [
}
dir="ltr"
>
<div
aria-label="Pivot Overflow Menu Example"
role="toolbar"
>
<div>
<div
aria-label="Pivot Overflow Menu Example"
className=
ms-FocusZone
ms-Pivot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

exports[`Component Examples renders Pivot.Override.Example.tsx correctly 1`] = `
<div>
<div
aria-label="Override Selected Item Pivot Example"
role="toolbar"
>
<div>
<div
aria-label="Override Selected Item Pivot Example"
className=
ms-FocusZone
ms-Pivot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

exports[`Component Examples renders Pivot.Remove.Example.tsx correctly 1`] = `
<div>
<div
aria-label="Remove Pivot Example"
role="toolbar"
>
<div>
<div
aria-label="Remove Pivot Example"
className=
ms-FocusZone
ms-Pivot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ exports[`Component Examples renders Pivot.Separate.Example.tsx correctly 1`] = `
}
}
/>
<div
aria-label="Separately Rendered Content Pivot Example"
role="toolbar"
>
<div>
<div
aria-label="Separately Rendered Content Pivot Example"
className=
ms-FocusZone
ms-Pivot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

exports[`Component Examples renders Pivot.Tabs.Example.tsx correctly 1`] = `
<div>
<div
aria-label="Links of Tab Style Pivot Example"
role="toolbar"
>
<div>
<div
aria-label="Links of Tab Style Pivot Example"
className=
ms-FocusZone
ms-Pivot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

exports[`Component Examples renders Pivot.TabsLarge.Example.tsx correctly 1`] = `
<div>
<div
aria-label="Links of Large Tabs Pivot Example"
role="toolbar"
>
<div>
<div
aria-label="Links of Large Tabs Pivot Example"
className=
ms-FocusZone
ms-Pivot
Expand Down
12 changes: 10 additions & 2 deletions packages/react/src/components/Pivot/Pivot.base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ export const PivotBase: React.FunctionComponent<IPivotProps> = React.forwardRef<
const { componentRef, theme, linkSize, linkFormat, overflowBehavior, focusZoneProps } = props;

let classNames: { [key in keyof IPivotStyles]: string };
const divProps = getNativeProps<React.HTMLAttributes<HTMLDivElement>>(props, divProperties);
const nameProps = {
'aria-label': props['aria-label'],
'aria-labelledby': props['aria-labelledby'],
};
const divProps = getNativeProps<React.HTMLAttributes<HTMLDivElement>>(props, divProperties, [
'aria-label',
'aria-labelledby',
]);

let linkCollection = getLinkItems(props, pivotId);

Expand Down Expand Up @@ -251,10 +258,11 @@ export const PivotBase: React.FunctionComponent<IPivotProps> = React.forwardRef<
});

return (
<div role="toolbar" {...divProps} ref={ref}>
<div ref={ref} {...divProps}>
<FocusZone
componentRef={focusZoneRef}
role="tablist"
{...nameProps}
direction={FocusZoneDirection.horizontal}
{...focusZoneProps}
className={css(classNames.root, focusZoneProps?.className)}
Expand Down
12 changes: 12 additions & 0 deletions packages/react/src/components/Pivot/Pivot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,16 @@ describe('Pivot', () => {
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
it('passes aria-label and aria-labelledby to tablist', () => {
const wrapper = mount(
<Pivot aria-label="test label" aria-labelledby="testID" data-foo="not passed to tablist">
<PivotItem headerText="Test Link 1" />
<PivotItem headerText="" />
</Pivot>,
);
const tablistElement = wrapper.find('div[role="tablist"]');
expect(tablistElement.prop('aria-label')).toBe('test label');
expect(tablistElement.prop('aria-labelledby')).toBe('testID');
expect(tablistElement.prop('data-foo')).toBeUndefined();
});
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Pivot renders link Pivot correctly 1`] = `
<div
role="toolbar"
>
<div>
<div
className=
ms-FocusZone
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Pivot renders Pivot correctly when itemCount is a string 1`] = `
<div
role="toolbar"
>
<div>
<div
className=
ms-FocusZone
Expand Down Expand Up @@ -400,7 +398,6 @@ exports[`Pivot renders Pivot correctly when itemCount is a string 1`] = `
exports[`Pivot renders Pivot correctly with custom className 1`] = `
<div
className="specialClassName"
role="toolbar"
>
<div
className=
Expand Down Expand Up @@ -786,9 +783,7 @@ exports[`Pivot renders Pivot correctly with custom className 1`] = `
`;
exports[`Pivot renders Pivot correctly with icon, text and count 1`] = `
<div
role="toolbar"
>
<div>
<div
className=
ms-FocusZone
Expand Down Expand Up @@ -1365,9 +1360,7 @@ exports[`Pivot renders Pivot correctly with icon, text and count 1`] = `
`;
exports[`Pivot renders Pivot with overflow 1`] = `
<div
role="toolbar"
>
<div>
<div
className=
ms-FocusZone
Expand Down Expand Up @@ -1930,9 +1923,7 @@ exports[`Pivot renders Pivot with overflow 1`] = `
`;
exports[`Pivot renders large link Pivot correctly 1`] = `
<div
role="toolbar"
>
<div>
<div
className=
ms-FocusZone
Expand Down Expand Up @@ -2316,9 +2307,7 @@ exports[`Pivot renders large link Pivot correctly 1`] = `
`;
exports[`Pivot renders large tabbed Pivot correctly 1`] = `
<div
role="toolbar"
>
<div>
<div
className=
ms-FocusZone
Expand Down Expand Up @@ -2773,9 +2762,7 @@ exports[`Pivot renders large tabbed Pivot correctly 1`] = `
`;
exports[`Pivot renders link Pivot correctly 1`] = `
<div
role="toolbar"
>
<div>
<div
className=
ms-FocusZone
Expand Down Expand Up @@ -3158,9 +3145,7 @@ exports[`Pivot renders link Pivot correctly 1`] = `
`;
exports[`Pivot renders tabbed Pivot correctly 1`] = `
<div
role="toolbar"
>
<div>
<div
className=
ms-FocusZone
Expand Down Expand Up @@ -3614,9 +3599,7 @@ exports[`Pivot renders tabbed Pivot correctly 1`] = `
`;
exports[`Pivot supports JSX expressions 1`] = `
<div
role="toolbar"
>
<div>
<div
className=
ms-FocusZone
Expand Down

0 comments on commit 6f07e52

Please sign in to comment.