Skip to content

Commit 560d76a

Browse files
committed
feat(ByRole): Allow filter by disabled state
1 parent 96380af commit 560d76a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/queries/byrole.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ getByRole(
2525
pressed?: boolean,
2626
suggest?: boolean,
2727
current?: boolean | string,
28+
disabled?: boolean,
2829
expanded?: boolean,
2930
queryFallbacks?: boolean,
3031
level?: number,
@@ -184,6 +185,28 @@ you can get the "👍" button by calling `getByRole('button', { pressed: true })
184185
To learn more about the pressed state see
185186
[ARIA `aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed).
186187

188+
### `disabled`
189+
190+
You can filter elements by their disabled state by setting `disabled: true` or
191+
`disabled: false`.
192+
193+
For example in
194+
195+
```html
196+
<body>
197+
<section>
198+
<button disabled>Login</button>
199+
<div role="alert" aria-disabled="false">Failed to login</button>
200+
</section>
201+
</body>
202+
```
203+
204+
you can get the "Login" button by calling
205+
`getByRole('button', { disabled: true })`. To learn more about the disabled
206+
state see
207+
[ARIA `aria-disabled`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed) and
208+
[MDN `disabled` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled).
209+
187210
### `suggest`
188211

189212
You can disable the ability to

0 commit comments

Comments
 (0)