-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Button: Beefing up accessibility tests and cleaning up state manageme…
…nt (#17155) * Button: Beefing up accessibility tests and cleaning up state management. * Change files * Updating change file. * Updating snapshots. * Removing unused imports. * Fixing lint error. Co-authored-by: KHMakoto <humberto_makoto@hotmail.com>
- Loading branch information
Showing
7 changed files
with
220 additions
and
69 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-button-e1acb3ed-0311-42c0-b9ec-468f986666b9.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Button: Beefing up accessibility tests and cleaning up state management.", | ||
"packageName": "@fluentui/react-button", | ||
"email": "Humberto.Morimoto@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/a11y-testing/src/definitions/react-button/buttonAccessibilityBehaviorDefinition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { Rule } from './../../types'; | ||
import { BehaviorRule } from './../../rules/rules'; | ||
|
||
export const buttonAccessibilityBehaviorDefinition: Rule[] = [ | ||
BehaviorRule.root() | ||
.doesNotHaveAttribute('role') | ||
.doesNotHaveAttribute('tabindex') | ||
.description(`if element is rendered as a default 'button'.`), | ||
// BehaviorRule.root() | ||
// .forProps({ href: '#' }) | ||
// .hasAttribute('role', 'button') | ||
// .hasAttribute('tabindex', '0') | ||
// .description(`if element has href and is rendered as an 'anchor'.`), | ||
BehaviorRule.root() | ||
.forProps({ as: 'div' }) | ||
.hasAttribute('data-is-focusable', 'true') | ||
.hasAttribute('role', 'button') | ||
.hasAttribute('tabindex', '0') | ||
.description(`if element type is other than the defaults 'anchor' and 'button'.`), | ||
BehaviorRule.root() | ||
.forProps({ disabled: true }) | ||
.hasAttribute('disabled') | ||
.description(`if element is rendered as a default 'button' and is disabled.`), | ||
// BehaviorRule.root() | ||
// .forProps({ disabled: true, href: '#' }) | ||
// .doesNotHaveAttribute('disabled') | ||
// .description(`if element has href and is rendered as an 'anchor' and is disabled.`), | ||
BehaviorRule.root() | ||
.forProps({ as: 'div', disabled: true }) | ||
.doesNotHaveAttribute('disabled') | ||
.description(`if element type is other than the defaults 'anchor' and 'button' and is disabled.`), | ||
// BehaviorRule.root() | ||
// .forProps({ disabledFocusable: true }) | ||
// .doesNotHaveAttribute('disabled') | ||
// .hasAttribute('aria-disabled', 'true') | ||
// .description(`if element is rendered as a default 'button' and is disabled but focusable.`), | ||
// BehaviorRule.root() | ||
// .forProps({ disabledFocusable: true, href: '#' }) | ||
// .doesNotHaveAttribute('disabled') | ||
// .hasAttribute('aria-disabled', 'true') | ||
// .hasAttribute('tabindex', '0') | ||
// .description(`if element has href and is rendered as an 'anchor' and is disabled but focusable.`), | ||
// BehaviorRule.root() | ||
// .forProps({ as: 'div', disabledFocusable: true }) | ||
// .doesNotHaveAttribute('disabled') | ||
// .hasAttribute('aria-disabled', 'true') | ||
// .hasAttribute('tabindex', '0') | ||
// .description(`if element type is other than the defaults 'anchor' and 'button' and is disabled but focusable.`), | ||
// BehaviorRule.root() | ||
// .forProps({ disabled: true, disabledFocusable: true }) | ||
// .doesNotHaveAttribute('disabled') | ||
// .hasAttribute('aria-disabled', 'true') | ||
// .description(`if element is rendered as a default 'button' and is disabled but focusable.`), | ||
// BehaviorRule.root() | ||
// .forProps({ disabled: true, disabledFocusable: true, href: '#' }) | ||
// .doesNotHaveAttribute('disabled') | ||
// .hasAttribute('aria-disabled', 'true') | ||
// .hasAttribute('tabindex', '0') | ||
// .description(`if element has href and is rendered as an 'anchor' and is disabled but focusable.`), | ||
// BehaviorRule.root() | ||
// .forProps({ as: 'div', disabled: true, disabledFocusable: true }) | ||
// .doesNotHaveAttribute('disabled') | ||
// .hasAttribute('aria-disabled', 'true') | ||
// .hasAttribute('tabindex', '0') | ||
// .description(`if element type is other than the defaults 'anchor' and 'button' and is disabled but focusable.`), | ||
BehaviorRule.root() | ||
.forProps({ as: 'div' }) | ||
.pressSpaceKey() | ||
.verifyOnclickExecution() | ||
.description(`if element type is other than the defaults 'anchor' and 'button'.`), | ||
BehaviorRule.root() | ||
.forProps({ as: 'div' }) | ||
.pressEnterKey() | ||
.verifyOnclickExecution() | ||
.description(`if element type is other than the defaults 'anchor' and 'button'.`), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 6 additions & 10 deletions
16
packages/react-button/src/components/Button/__snapshots__/Button.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Button renders a default state 1`] = ` | ||
<button | ||
className="" | ||
onKeyDown={[Function]} | ||
> | ||
<span | ||
className="" | ||
> | ||
Default button | ||
exports[`Button renders a default button 1`] = ` | ||
"<button onClick={[Function]} onKeyDown={[Function]} aria-disabled={[undefined]} disabled={[undefined]} className=\\"\\"> | ||
<Component /> | ||
<span className=\\"\\"> | ||
This is a button | ||
</span> | ||
</button> | ||
</button>" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters