Skip to content

Commit 6faebe4

Browse files
committed
Add example for hidden
1 parent fd3f540 commit 6faebe4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

docs/dom-testing-library/api-queries.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,11 +549,22 @@ If you set `hidden` to `true` elements that are normally excluded from the
549549
accessibility tree are considered for the query as well. The default behavior
550550
follows https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion with the exception of
551551
`role="none"` and `role="presentation"` which are considered in the query in any
552-
case.
552+
case. For example in
553553

554554
```html
555-
<div role="dialog">...</div>
556-
```
555+
<body>
556+
<main aria-hidden="true">
557+
<button>Open dialog</button>
558+
</main>
559+
<div role="dialog">
560+
<button>Close dialog</button>
561+
</div>
562+
</body>
563+
```
564+
565+
`getByRole('button')` would only return the `Close dialog`-button. To make
566+
assertions about the `Open dialog`-button you would need to use
567+
`getAllByRole('button', { hidden: true })`.
557568

558569
<!--DOCUSAURUS_CODE_TABS-->
559570

0 commit comments

Comments
 (0)