From 53d02e88719726881191269b8f40db89dd66b513 Mon Sep 17 00:00:00 2001 From: "Geoff Cox (Microsoft)" Date: Fri, 14 Jan 2022 15:15:55 -0800 Subject: [PATCH] Added aria-orientation to divider (#21292) * Added aria-orientation to divider * Change files * Fixed vertical tests to be vertical --- ...-8007dcbe-33ef-4d80-9b15-0cfca85bdc66.json | 7 ++ .../src/components/Divider/Divider.test.tsx | 26 +++-- .../__snapshots__/Divider.test.tsx.snap | 110 ++++++++++-------- .../src/components/Divider/useDivider.ts | 1 + 4 files changed, 85 insertions(+), 59 deletions(-) create mode 100644 change/@fluentui-react-divider-8007dcbe-33ef-4d80-9b15-0cfca85bdc66.json diff --git a/change/@fluentui-react-divider-8007dcbe-33ef-4d80-9b15-0cfca85bdc66.json b/change/@fluentui-react-divider-8007dcbe-33ef-4d80-9b15-0cfca85bdc66.json new file mode 100644 index 00000000000000..c8f8be788abcd7 --- /dev/null +++ b/change/@fluentui-react-divider-8007dcbe-33ef-4d80-9b15-0cfca85bdc66.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Added aria-orientation to divider", + "packageName": "@fluentui/react-divider", + "email": "gcox@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/react-divider/src/components/Divider/Divider.test.tsx b/packages/react-divider/src/components/Divider/Divider.test.tsx index 9d70bbcf0e0f46..2835303292749d 100644 --- a/packages/react-divider/src/components/Divider/Divider.test.tsx +++ b/packages/react-divider/src/components/Divider/Divider.test.tsx @@ -32,43 +32,43 @@ describe('Divider', () => { expect(tree).toMatchSnapshot(); }); - it('renders a subtle state with content', () => { + it('renders a subtle appearance', () => { const component = renderer.create(Subtle); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); - it('renders a brand state with content', () => { + it('renders a brand appearance', () => { const component = renderer.create(Brand); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); - it('renders a strong state with content', () => { + it('renders a strong appearance', () => { const component = renderer.create(Strong); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); - it('renders a content aligned start', () => { + it('renders content start aligned', () => { const component = renderer.create(Start); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); - it('renders a content aligned center', () => { + it('renders content center aligned', () => { const component = renderer.create(Center); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); - it('renders a content aligned end', () => { + it('renders content end aligned', () => { const component = renderer.create(End); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); - it('renders a divider with different color', () => { + it('renders a divider with a different color', () => { const component = renderer.create(); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); @@ -81,18 +81,22 @@ describe('Divider', () => { }); it('renders a vertical divider with content', () => { - const component = renderer.create(Vertical); + const component = renderer.create(Vertical); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); - it('renders a vertical a fixed height', () => { - const component = renderer.create(fixed 100px height); + it('renders a vertical divider with a fixed height', () => { + const component = renderer.create( + + fixed 100px height + , + ); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); - it('renders a horizontal a fixed width', () => { + it('renders a horizontal divider with a fixed width', () => { const component = renderer.create(fixed 100px width); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); diff --git a/packages/react-divider/src/components/Divider/__snapshots__/Divider.test.tsx.snap b/packages/react-divider/src/components/Divider/__snapshots__/Divider.test.tsx.snap index 558c9fe3fd2ac0..706427042ce317 100644 --- a/packages/react-divider/src/components/Divider/__snapshots__/Divider.test.tsx.snap +++ b/packages/react-divider/src/components/Divider/__snapshots__/Divider.test.tsx.snap @@ -1,8 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Divider renders a brand state with content 1`] = ` +exports[`Divider renders a brand appearance 1`] = `
@@ -14,173 +15,186 @@ exports[`Divider renders a brand state with content 1`] = `
`; -exports[`Divider renders a content aligned center 1`] = ` +exports[`Divider renders a default divider 1`] = ` +
+`; + +exports[`Divider renders a divider with a different color 1`] = ` +
+`; + +exports[`Divider renders a divider with content 1`] = `
- Center + Default Divider
`; -exports[`Divider renders a content aligned end 1`] = ` +exports[`Divider renders a divider with inset 1`] = `
- End + Inset
`; -exports[`Divider renders a content aligned start 1`] = ` +exports[`Divider renders a horizontal divider with a fixed width 1`] = `
- Start + fixed 100px width
`; -exports[`Divider renders a default divider 1`] = ` -
-`; - -exports[`Divider renders a divider with content 1`] = ` +exports[`Divider renders a strong appearance 1`] = `
- Default Divider + Strong
`; -exports[`Divider renders a divider with different color 1`] = ` -
-`; - -exports[`Divider renders a divider with inset 1`] = ` +exports[`Divider renders a subtle appearance 1`] = `
- Inset + Subtle
`; -exports[`Divider renders a horizontal a fixed width 1`] = ` +exports[`Divider renders a vertical divider 1`] = ` +
+`; + +exports[`Divider renders a vertical divider with a fixed height 1`] = `
- fixed 100px width + fixed 100px height
`; -exports[`Divider renders a strong state with content 1`] = ` +exports[`Divider renders a vertical divider with content 1`] = `
- Strong + Vertical
`; -exports[`Divider renders a subtle state with content 1`] = ` +exports[`Divider renders content center aligned 1`] = `
- Subtle + Center
`; -exports[`Divider renders a vertical a fixed height 1`] = ` +exports[`Divider renders content end aligned 1`] = `
- fixed 100px height + End
`; -exports[`Divider renders a vertical divider 1`] = ` -
-`; - -exports[`Divider renders a vertical divider with content 1`] = ` +exports[`Divider renders content start aligned 1`] = `
- Vertical + Start
`; diff --git a/packages/react-divider/src/components/Divider/useDivider.ts b/packages/react-divider/src/components/Divider/useDivider.ts index b1215e0e9ec3b3..65c94b4c733e5b 100644 --- a/packages/react-divider/src/components/Divider/useDivider.ts +++ b/packages/react-divider/src/components/Divider/useDivider.ts @@ -28,6 +28,7 @@ export const useDivider = (props: DividerProps, ref: React.Ref): Di ...props, ref, role: 'separator', + 'aria-orientation': vertical ? 'vertical' : 'horizontal', 'aria-labelledby': props.children ? dividerId : undefined, }), wrapper: resolveShorthand(wrapper, {