Skip to content

Commit

Permalink
fix: Keytip passes through describedBy id if passed in (#33048)
Browse files Browse the repository at this point in the history
  • Loading branch information
smhigley authored Oct 16, 2024
1 parent e587e1f commit 1696fc2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: Keytip passes through describedBy id if passed in",
"packageName": "@fluentui/react",
"email": "sarah.higley@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,25 @@ describe('ContextualMenuButton', () => {

renderMock.mockRestore();
});

it('renders a description when ariaDescription is passed in', () => {
const component = mount(
<ContextualMenuButton
item={{ ...menuItem, ariaDescription: 'test' }}
classNames={menuClassNames}
index={0}
focusableElementIndex={0}
totalItemCount={1}
hasCheckmarks={true}
/>,
);

const descriptionId = component.find('button').at(0).getDOMNode().getAttribute('aria-describedby');
expect(descriptionId).toBeTruthy();

const descriptionEl = component.find(`#${descriptionId}`).at(0);
expect(descriptionEl.text()).toEqual('test');
});
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/KeytipData/useKeytipData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function useKeytipData(options: KeytipDataOptions): IKeytipData {
}, []);

let nativeKeytipProps: IKeytipData = {
ariaDescribedBy: undefined,
ariaDescribedBy: options.ariaDescribedBy,
keytipId: undefined,
};

Expand Down

0 comments on commit 1696fc2

Please sign in to comment.