From 7c0cd5baad22e6feede67b7459632ea8b6da3c0f Mon Sep 17 00:00:00 2001 From: Alex Krolick Date: Thu, 11 Jul 2019 16:06:01 -0700 Subject: [PATCH] feat(media): add aria-label prop to media.menu --- src/components/media/Media.md | 2 +- src/components/media/MediaMenu.js | 6 ++++-- src/components/media/__tests__/MediaMenu-test.js | 11 +++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 src/components/media/__tests__/MediaMenu-test.js diff --git a/src/components/media/Media.md b/src/components/media/Media.md index 507b9c3514e..a88e50fb190 100644 --- a/src/components/media/Media.md +++ b/src/components/media/Media.md @@ -17,7 +17,7 @@ const { MenuItem } = require('../menu'); - + Edit Delete diff --git a/src/components/media/MediaMenu.js b/src/components/media/MediaMenu.js index 54d4b61bed8..13124f5e100 100644 --- a/src/components/media/MediaMenu.js +++ b/src/components/media/MediaMenu.js @@ -15,13 +15,15 @@ type Props = { className?: string, /** is the dropdown menu button disabled */ isDisabled: boolean, + /** aria-label prop for button icon */ + label?: string, }; -function MediaMenu({ className, children, isDisabled = false, ...rest }: Props) { +function MediaMenu({ className, children, isDisabled = false, label, ...rest }: Props) { return (
- + {children} diff --git a/src/components/media/__tests__/MediaMenu-test.js b/src/components/media/__tests__/MediaMenu-test.js new file mode 100644 index 00000000000..ee8ec2b43c7 --- /dev/null +++ b/src/components/media/__tests__/MediaMenu-test.js @@ -0,0 +1,11 @@ +import React from 'react'; + +import MediaMenu from '../MediaMenu'; + +describe('components/Media/MediaMenu', () => { + test('label prop adds aria-label attribute to menu button', () => { + const label = 'Open options'; + const wrapper = shallow(); + expect(wrapper.find('PlainButton').prop('aria-label')).toBe(label); + }); +});