Skip to content
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

Merged
merged 11 commits into from
Mar 25, 2021

Conversation

khmakoto
Copy link
Member

Pull request checklist

Description of changes

This PR does a couple of things:

  • Adds new accessibility tests for the Button component under the @fluentui/a11y-testing package.
  • Cleans up the useButtonState hook and some of the tests under the @fluentui/react-button package.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 24, 2021

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:

Sandbox Source
Fluent UI Button Configuration
codesandbox-react-template Configuration
codesandbox-react-northstar-template Configuration

@fabricteam
Copy link
Collaborator

fabricteam commented Feb 24, 2021

Perf Analysis

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 979 990 5000
BaseButton mount 988 977 5000
Breadcrumb mount 42635 42454 5000
ButtonNext mount 525 579 5000
Checkbox mount 1674 1664 5000
CheckboxBase mount 1380 1393 5000
ChoiceGroup mount 4968 5006 5000
ComboBox mount 1014 1060 1000
CommandBar mount 10208 10595 1000
ContextualMenu mount 6190 6345 1000
DefaultButton mount 1241 1201 5000
DetailsRow mount 3764 3893 5000
DetailsRowFast mount 3795 3760 5000
DetailsRowNoStyles mount 3616 3555 5000
Dialog mount 1560 1550 1000
DocumentCardTitle mount 1770 1792 1000
Dropdown mount 3470 3492 5000
FocusTrapZone mount 1823 1867 5000
FocusZone mount 1812 1792 5000
IconButton mount 1855 1897 5000
Label mount 340 348 5000
Layer mount 1865 1976 5000
Link mount 485 484 5000
MakeStyles mount 1699 1692 50000
MenuButton mount 1555 1599 5000
MessageBar mount 2044 2011 5000
Nav mount 3477 3435 1000
OverflowSet mount 1066 1026 5000
Panel mount 1475 1459 1000
Persona mount 862 890 1000
Pivot mount 1457 1458 1000
PrimaryButton mount 1363 1348 5000
Rating mount 8454 8178 5000
SearchBox mount 1426 1423 5000
Shimmer mount 2718 2792 5000
Slider mount 2053 2097 5000
SpinButton mount 5200 5228 5000
Spinner mount 433 446 5000
SplitButton mount 3337 3382 5000
Stack mount 529 536 5000
StackWithIntrinsicChildren mount 1663 1682 5000
StackWithTextChildren mount 4946 4988 5000
SwatchColorPicker mount 10761 10853 5000
Tabs mount 1519 1479 1000
TagPicker mount 3060 3065 5000
TeachingBubble mount 12158 11809 5000
Text mount 470 465 5000
TextField mount 1456 1478 5000
ThemeProvider mount 1210 1213 5000
ThemeProvider virtual-rerender 586 597 5000
ThemeProviderNext mount 15110 15520 5000
Toggle mount 818 860 5000
buttonNative mount 112 117 5000

Perf Analysis (Fluent)

Perf comparison
Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🦄 Avatar.Fluent 0.19 0.49 0.39:1 2000 372
🦄 Button.Fluent 0.13 0.21 0.62:1 5000 667
🔧 Checkbox.Fluent 0.67 0.36 1.86:1 1000 667
🎯 Dialog.Fluent 0.17 0.22 0.77:1 5000 849
🔧 Dropdown.Fluent 3.17 0.42 7.55:1 1000 3166
🔧 Icon.Fluent 0.15 0.06 2.5:1 5000 735
🦄 Image.Fluent 0.09 0.13 0.69:1 5000 443
🔧 Slider.Fluent 1.64 0.47 3.49:1 1000 1644
🔧 Text.Fluent 0.08 0.03 2.67:1 5000 407
🦄 Tooltip.Fluent 0.15 0.89 0.17:1 5000 761

🔧 Needs work     🎯 On target     🦄 Amazing

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
ChatDuplicateMessagesPerf.default 340 298 1.14:1
SegmentMinimalPerf.default 424 393 1.08:1
AvatarMinimalPerf.default 233 218 1.07:1
VideoMinimalPerf.default 747 700 1.07:1
CarouselMinimalPerf.default 535 504 1.06:1
ImageMinimalPerf.default 471 444 1.06:1
ListNestedPerf.default 656 619 1.06:1
Button.Fluent 667 629 1.06:1
FormMinimalPerf.default 486 462 1.05:1
HeaderMinimalPerf.default 439 417 1.05:1
TreeWith60ListItems.default 215 204 1.05:1
Tooltip.Fluent 761 726 1.05:1
AttachmentMinimalPerf.default 190 183 1.04:1
BoxMinimalPerf.default 421 405 1.04:1
ButtonMinimalPerf.default 211 202 1.04:1
CardMinimalPerf.default 641 617 1.04:1
PortalMinimalPerf.default 171 164 1.04:1
ProviderMinimalPerf.default 1065 1026 1.04:1
Checkbox.Fluent 667 642 1.04:1
Image.Fluent 443 427 1.04:1
Text.Fluent 407 393 1.04:1
ChatWithPopoverPerf.default 421 410 1.03:1
DividerMinimalPerf.default 431 417 1.03:1
LabelMinimalPerf.default 480 465 1.03:1
ButtonSlotsPerf.default 628 613 1.02:1
DropdownManyItemsPerf.default 810 795 1.02:1
GridMinimalPerf.default 395 389 1.02:1
PopupMinimalPerf.default 742 726 1.02:1
RadioGroupMinimalPerf.default 508 499 1.02:1
IconMinimalPerf.default 735 722 1.02:1
CustomToolbarPrototype.default 3966 3877 1.02:1
Dialog.Fluent 849 834 1.02:1
AttachmentSlotsPerf.default 1261 1251 1.01:1
ButtonUseCssPerf.default 895 885 1.01:1
ChatMinimalPerf.default 708 698 1.01:1
EmbedMinimalPerf.default 4418 4388 1.01:1
ItemLayoutMinimalPerf.default 1344 1335 1.01:1
StatusMinimalPerf.default 777 773 1.01:1
TextAreaMinimalPerf.default 581 576 1.01:1
AlertMinimalPerf.default 338 339 1:1
ButtonOverridesMissPerf.default 1773 1775 1:1
LayoutMinimalPerf.default 445 444 1:1
ListMinimalPerf.default 551 553 1:1
SliderMinimalPerf.default 1615 1623 1:1
SplitButtonMinimalPerf.default 4036 4034 1:1
TableManyItemsPerf.default 2260 2257 1:1
ToolbarMinimalPerf.default 1052 1055 1:1
Dropdown.Fluent 3166 3156 1:1
Icon.Fluent 735 736 1:1
Slider.Fluent 1644 1638 1:1
AccordionMinimalPerf.default 178 180 0.99:1
AnimationMinimalPerf.default 431 434 0.99:1
CheckboxMinimalPerf.default 2893 2930 0.99:1
DropdownMinimalPerf.default 3137 3159 0.99:1
ListCommonPerf.default 734 738 0.99:1
LoaderMinimalPerf.default 743 754 0.99:1
MenuMinimalPerf.default 950 955 0.99:1
MenuButtonMinimalPerf.default 1688 1699 0.99:1
ProviderMergeThemesPerf.default 1596 1612 0.99:1
SkeletonMinimalPerf.default 419 422 0.99:1
TableMinimalPerf.default 456 461 0.99:1
Avatar.Fluent 372 376 0.99:1
ButtonUseCssNestingPerf.default 1163 1190 0.98:1
DatepickerMinimalPerf.default 48029 48947 0.98:1
DialogMinimalPerf.default 837 850 0.98:1
FlexMinimalPerf.default 331 338 0.98:1
HeaderSlotsPerf.default 915 931 0.98:1
InputMinimalPerf.default 1368 1390 0.98:1
ListWith60ListItems.default 671 684 0.98:1
ReactionMinimalPerf.default 442 450 0.98:1
RefMinimalPerf.default 233 237 0.98:1
TextMinimalPerf.default 399 407 0.98:1
TooltipMinimalPerf.default 1021 1041 0.98:1
RosterPerf.default 1265 1306 0.97:1
TreeMinimalPerf.default 886 940 0.94:1

@size-auditor
Copy link

size-auditor bot commented Feb 24, 2021

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: 0913259cdea5a3d692720299516aec613b7c072a (build)

@layershifter
Copy link
Member

@khmakoto Is there sense to wait for #17060, first?

@khmakoto
Copy link
Member Author

khmakoto commented Feb 24, 2021

@khmakoto Makoto Morimoto Burgos FTE Is there sense to wait for #17060, first?

@layershifter yeah, let's do that. I've added the Do Not Merge tag and won't remove it until #17060 goes in.

Comment on lines +9 to +13
// BehaviorRule.root()
// .forProps({ href: '#' })
// .hasAttribute('role', 'button')
// .hasAttribute('tabindex', '0')
// .description(`if element has href and is rendered as an 'anchor'.`),
Copy link
Member Author

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.

Copy link
Member

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

@ecraig12345
Copy link
Member

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.

msft-fluent-ui-bot pushed a commit that referenced this pull request Mar 2, 2021
…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;
Copy link
Contributor

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?

Copy link
Member Author

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.
Copy link
Member

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.

Copy link
Member

@dzearing dzearing Mar 25, 2021

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

Copy link
Member Author

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.

joshualamusga1 pushed a commit to joshualamusga1/fluentui that referenced this pull request Mar 25, 2021
…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)
@khmakoto khmakoto enabled auto-merge (squash) March 25, 2021 17:52
@khmakoto khmakoto merged commit ce4d441 into microsoft:master Mar 25, 2021
@khmakoto khmakoto deleted the buttonTestsAndState branch March 25, 2021 19:14
@msft-fluent-ui-bot
Copy link
Collaborator

🎉@fluentui/react-button@v9.0.0-alpha.16 has been released which incorporates this pull request.:tada:

Handy links:

miroslavstastny pushed a commit to miroslavstastny/fluentui that referenced this pull request May 5, 2021
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants