Skip to content

Commit

Permalink
feat(getByRole): Allow filter by disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kemuridama committed May 8, 2023
1 parent b5c63d9 commit f339701
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/queries/byrole.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ getByRole(
expanded?: boolean,
queryFallbacks?: boolean,
level?: number,
disabled?: boolean,
value?: {
min?: number,
max?: number,
Expand Down Expand Up @@ -444,3 +445,32 @@ You can query a specific element like this
```js
getByRole('alertdialog', {description: 'Your session is about to expire'})
```

### `disabled`

You can filter the returned elements by their disabled state by setting
`disabled: true`, `disabled: false`, `aria-disabled: true` or
`aria-disabled: false`.

For example in

```html
<body>
<button disabled>disabled</button>
<button aria-disabled="true">aria-disabled</button>
<button>normal</button>
</body>
```

you can query a specific element(s) like this

```js
getAllByRole('button', {disabled: true})
// [
// <button disabled>disabled</button>,
// <button aria-disabled="true">aria-disabled</button>
// ]

getByRole('button', {disabled: false})
// <button>normal</button>
```

0 comments on commit f339701

Please sign in to comment.