Skip to content

feat(byRole): add documentation for new option (aria-current) of ByRole queries #822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/queries/byrole.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ getByRole(
selected?: boolean,
checked?: boolean,
pressed?: boolean,
current?: boolean | string,
expanded?: boolean,
queryFallbacks?: boolean,
level?: number,
Expand Down Expand Up @@ -142,6 +143,27 @@ state and which elements can have this state see
> Checkboxes have a "mixed" state, which is considered neither checked nor
> unchecked (details [here](https://www.w3.org/TR/html-aam-1.0/#details-id-56)).

### `current`

You can filter the returned elements by their current state by setting
`current: boolean | string`.
Note that no `aria-current` attribute will match `current: false` since `false` is the default value for `aria-current`.

For example in

```html
<body>
<nav>
<a href="current/page" aria-current="true">👍</a>
<a href="another/page">👎</a>
</nav>
</body>
```

you can get the "👍" link by calling `getByRole('link', { current: true })` and the "👎" by calling `getByRole('link', { current: false })`.
To learn more about the current state see
[ARIA `aria-current`](https://www.w3.org/TR/wai-aria-1.2/#aria-current).

### `pressed`

Buttons can have a pressed state. You can filter the returned elements by their
Expand Down