Skip to content

Commit c9b362c

Browse files
committed
feat(byRole): add documentation for new option of ByRole queries
- docs for PR: testing-library/dom-testing-library#943 - according to issue: testing-library/dom-testing-library#864
1 parent 333fbd2 commit c9b362c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/queries/byrole.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ getByRole(
2424
selected?: boolean,
2525
checked?: boolean,
2626
pressed?: boolean,
27+
current?: boolean,
2728
expanded?: boolean,
2829
queryFallbacks?: boolean,
2930
level?: number,
@@ -162,6 +163,32 @@ you can get the "👍" button by calling `getByRole('button', { pressed: true })
162163
To learn more about the pressed state see
163164
[ARIA `aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed).
164165

166+
### `current`
167+
168+
Elements can represent the current item within a container or set of related
169+
elements.
170+
171+
Despite current have list of values: `date`, `location`, `page`, `step`, `time`,
172+
`true`, `false`
173+
174+
You can filter the returned elements by their current status by setting
175+
`current: true` (for any valid value) or `current: false` (for false).
176+
177+
For example in
178+
179+
```html
180+
<body>
181+
<section>
182+
<link href="current/page" aria-current="true">👍</link>
183+
<link href="another/page" aria-current="false">👎</link>
184+
</section>
185+
</body>
186+
```
187+
188+
you can get the "👍" link by calling `getByRole('button', { current: true })`.
189+
To learn more about the current status see
190+
[ARIA `aria-current`](https://www.w3.org/TR/wai-aria-1.2/#aria-current).
191+
165192
### `expanded`
166193

167194
You can filter the returned elements by their expanded state by setting

0 commit comments

Comments
 (0)