Skip to content

Commit

Permalink
feat(media): add aria-label prop to media.menu
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkrolick committed Jul 11, 2019
1 parent 3e21d7e commit 7c0cd5b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/media/Media.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { MenuItem } = require('../menu');
</Media.Figure>

<Media.Body>
<Media.Menu>
<Media.Menu label="Options">
<MenuItem>Edit</MenuItem>
<MenuItem>Delete</MenuItem>
</Media.Menu>
Expand Down
6 changes: 4 additions & 2 deletions src/components/media/MediaMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className={classnames('bdl-Media-menu', className)} {...rest}>
<DropdownMenu constrainToScrollParent isRightAligned>
<PlainButton isDisabled={isDisabled} type="button">
<PlainButton isDisabled={isDisabled} type="button" aria-label={label}>
<IconEllipsis color={bdlGray62} height={16} width={16} />
</PlainButton>
<Menu>{children}</Menu>
Expand Down
11 changes: 11 additions & 0 deletions src/components/media/__tests__/MediaMenu-test.js
Original file line number Diff line number Diff line change
@@ -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(<MediaMenu label={label} />);
expect(wrapper.find('PlainButton').prop('aria-label')).toBe(label);
});
});

0 comments on commit 7c0cd5b

Please sign in to comment.