Skip to content

Commit

Permalink
fix: Set aria-modal on Popover if focus trap is enabled (#21387)
Browse files Browse the repository at this point in the history
* fix: Set `aria-modal` on Popover if focus trap is enabled

* Change files

* do not use aria-modal=false

* add test
  • Loading branch information
ling1726 authored Jan 24, 2022
1 parent fa717d7 commit c2706ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "fix: Set `aria-modal` on Popover if focus trap is enabled",
"packageName": "@fluentui/react-popover",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,13 @@ describe('PopoverSurface', () => {
// Assert
expect(queryByTestId(testid)).toBeNull();
});

it('should set aria-modal true if focus trap is active', () => {
// Arrange
mockPopoverContext({ open: true, trapFocus: true });
const { getByTestId } = render(<PopoverSurface data-testid={testid}>Content</PopoverSurface>);

// Assert
expect(getByTestId(testid).getAttribute('aria-modal')).toEqual('true');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const usePopoverSurface = (props: PopoverSurfaceProps, ref: React.Ref<HTM
root: getNativeElementProps('div', {
ref: useMergedRefs(ref, contentRef),
role: 'dialog',
'aria-modal': trapFocus ? true : undefined,
...modalAttributes,
...props,
}),
Expand Down

0 comments on commit c2706ce

Please sign in to comment.