Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerJDev committed Sep 20, 2024
1 parent 6ad6b65 commit d5b5ec9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/react/src/Overlay/Overlay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,13 @@ describe('Overlay', () => {
expect(queryByRole('dialog')).not.toBeInTheDocument()
expect(queryByRole('none')).toBeInTheDocument()
})

it('should add `aria-modal` if `role="dialog"` is present', async () => {
const user = userEvent.setup()
const {getByText, queryByRole} = render(<TestComponent role="dialog" />)

await user.click(getByText('open overlay'))

expect(queryByRole('dialog')).toHaveAttribute('aria-modal')
})
})
2 changes: 1 addition & 1 deletion packages/react/src/Overlay/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const Overlay = React.forwardRef<HTMLDivElement, OwnOverlayProps>(
const dialog = role && role !== 'dialog' ? true : false

useFocusTrap({
containerRef: overlayRef, // only if `role="dialog"`, `aria-modal="true"` is true
containerRef: overlayRef,
disabled: !focusTrap || dialog,
})

Expand Down

0 comments on commit d5b5ec9

Please sign in to comment.