From 560d76a0c36231bcf5be87f5ada8de2fb9b7afc4 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Thu, 9 Mar 2023 11:09:04 +0100 Subject: [PATCH 1/2] feat(ByRole): Allow filter by disabled state --- docs/queries/byrole.mdx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/queries/byrole.mdx b/docs/queries/byrole.mdx index 265d741d..28a6b8e6 100644 --- a/docs/queries/byrole.mdx +++ b/docs/queries/byrole.mdx @@ -25,6 +25,7 @@ getByRole( pressed?: boolean, suggest?: boolean, current?: boolean | string, + disabled?: boolean, expanded?: boolean, queryFallbacks?: boolean, level?: number, @@ -184,6 +185,28 @@ you can get the "👍" button by calling `getByRole('button', { pressed: true }) To learn more about the pressed state see [ARIA `aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed). +### `disabled` + +You can filter elements by their disabled state by setting `disabled: true` or +`disabled: false`. + +For example in + +```html + +
+ +
Failed to login +
+ +``` + +you can get the "Login" button by calling +`getByRole('button', { disabled: true })`. To learn more about the disabled +state see +[ARIA `aria-disabled`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed) and +[MDN `disabled` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled). + ### `suggest` You can disable the ability to From 3268d1a4ec68f83d7b4e633f3e732f65889c98bb Mon Sep 17 00:00:00 2001 From: eps1lon Date: Thu, 9 Mar 2023 11:13:29 +0100 Subject: [PATCH 2/2] TODO: reword+fixup --- docs/queries/byrole.mdx | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/queries/byrole.mdx b/docs/queries/byrole.mdx index 28a6b8e6..a5109aad 100644 --- a/docs/queries/byrole.mdx +++ b/docs/queries/byrole.mdx @@ -165,47 +165,47 @@ the "👎" by calling `getByRole('link', { current: false })`. To learn more abo the current state see [ARIA `aria-current`](https://www.w3.org/TR/wai-aria-1.2/#aria-current). -### `pressed` +### `disabled` -Buttons can have a pressed state. You can filter the returned elements by their -pressed state by setting `pressed: true` or `pressed: false`. +You can filter elements by their disabled state by setting `disabled: true` or +`disabled: false`. For example in ```html
- - + +
Failed to login
``` -you can get the "👍" button by calling `getByRole('button', { pressed: true })`. -To learn more about the pressed state see -[ARIA `aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed). +you can get the "Login" button by calling +`getByRole('button', { disabled: true })`. To learn more about the disabled +state see +[ARIA `aria-disabled`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed) and +[MDN `disabled` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled). -### `disabled` +### `pressed` -You can filter elements by their disabled state by setting `disabled: true` or -`disabled: false`. +Buttons can have a pressed state. You can filter the returned elements by their +pressed state by setting `pressed: true` or `pressed: false`. For example in ```html
- -
Failed to login + +
``` -you can get the "Login" button by calling -`getByRole('button', { disabled: true })`. To learn more about the disabled -state see -[ARIA `aria-disabled`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed) and -[MDN `disabled` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled). +you can get the "👍" button by calling `getByRole('button', { pressed: true })`. +To learn more about the pressed state see +[ARIA `aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed). ### `suggest`