-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Button: Beefing up accessibility tests and cleaning up state management #17155
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a4d3a27:
|
Perf AnalysisNo significant results to display. All results
Perf Analysis (Fluent)Perf comparison
Perf tests with no regressions
|
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 0913259cdea5a3d692720299516aec613b7c072a (build) |
@layershifter yeah, let's do that. I've added the |
// BehaviorRule.root() | ||
// .forProps({ href: '#' }) | ||
// .hasAttribute('role', 'button') | ||
// .hasAttribute('tabindex', '0') | ||
// .description(`if element has href and is rendered as an 'anchor'.`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to know that I've commented for now the tests that reference commented props.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be worth adding that somewhere in this definition
Now that #17169 (final version 8 prep) has merged, you'll need to merge with master and update any "prerelease" change files to use either "patch" or "minor" as appropriate. |
…nction (#17086) #### Pull request checklist - [x] Addresses an existing issue: Part of #16572 - [x] Include a change request file using `$ yarn change` #### Description of changes This PR does a couple of things: - Adds vr-tests for the `Link` component in the `vr-tests` package. - Adds accessibility tests for the `Link` component as `linkBehaviorDefinition` in the `@fluentui/a11y-testing` package. - Cleans up the `useLinkState` hook and fixes some issues with it under the `@fluentui/react-link` package. - Adds behavioral and snapshot tests in the `@fluentui/react-link` package. - ~Cleans up the `buttonBehaviorDefinition` tests in the `@fluentui/a11y-testing` package.~ (Moved to #17155) - ~Cleans up the `useButtonState` hook and some of the tests under the `@fluentui/react-button` package.~ (Moved to #17155)
draftState.disabled = draftState.as === 'button' ? disabled /* && !disabledFocusable */ : undefined; | ||
// Set the aria-disabled and disabled props correctly. | ||
state['aria-disabled'] = disabled /*|| disabledFocusable*/; | ||
state.disabled = as === 'button' ? disabled /* && !disabledFocusable*/ : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will as
ever be undefined, or does it get defaulted to 'button'
somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gets defaulted in the useButton
hook before calling useButtonState
.
@@ -4,40 +4,56 @@ import { ButtonState } from './Button.types'; | |||
|
|||
/** | |||
* The useButton hook processes the Button draft state. | |||
* @param draftState - Button draft state to mutate. | |||
* @param state - Button draft state to mutate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On thing here is that judging from naming, i originally was thinking draftState
rather than simply state
as a variable name would be a better indication that the object will be mutated. Otherwise, especially now that it returns the state, it might be interpreted to not mutate like normal circumstances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is pretty clear that it mutates it of course, just not everyone thoroughly reads comments but they do read param names and might infer an expectation.
If there's a better term than draftState
, maybe partialState
or something... that is more clear, I think that would be better than calling it just state
. My 2c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using the convention that the other components have gone with. I can push back to get some better naming but that should probably not block this PR.
…nction (microsoft#17086) #### Pull request checklist - [x] Addresses an existing issue: Part of microsoft#16572 - [x] Include a change request file using `$ yarn change` #### Description of changes This PR does a couple of things: - Adds vr-tests for the `Link` component in the `vr-tests` package. - Adds accessibility tests for the `Link` component as `linkBehaviorDefinition` in the `@fluentui/a11y-testing` package. - Cleans up the `useLinkState` hook and fixes some issues with it under the `@fluentui/react-link` package. - Adds behavioral and snapshot tests in the `@fluentui/react-link` package. - ~Cleans up the `buttonBehaviorDefinition` tests in the `@fluentui/a11y-testing` package.~ (Moved to microsoft#17155) - ~Cleans up the `useButtonState` hook and some of the tests under the `@fluentui/react-button` package.~ (Moved to microsoft#17155)
🎉 Handy links: |
…nt (microsoft#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>
Pull request checklist
$ yarn change
Description of changes
This PR does a couple of things:
Button
component under the@fluentui/a11y-testing
package.useButtonState
hook and some of the tests under the@fluentui/react-button
package.