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

Allow ariaDescription as a prop on IContextualMenuItem #15770

Merged
merged 5 commits into from
Nov 12, 2020

Conversation

SavannahBourgeois
Copy link
Collaborator

Pull request checklist

Description of changes

There are a few props that can be set on items to help give screen reader users more context. One of those is aria-DescribedBy which is a string of IDs that point to elements describing the item. The other is aria-Description which is often set as the description of the element or is placed into a hidden span and the ID of that span is added to the list of IDs in aria-DescribedBy. This second approach is better because it will merge the aria-DescribedBy IDs and concat them to be the aria-Description set on the element so you do not overwrite other aria-DescribedBy elements.

With this change, I add ariaDescribedBy and ariaDescription as options on IContextualMenuItem. If the user passes ariaDescription, we will generate a hidden span with the contents of that prop and set the ID of that span to the list of aria-DescribedBy.

Some more in-depth explanation on why I did it the way I did. Each of the contextual menu items is set up slightly different to account for the differences in content. Each of these has a keytip wrapper and if the user passes in keytips, the aria-DescribedBy is updated to point to the element housing the keytip. If we set aria-DescribedBy directly on the element, we would overwrite the possible aria-describedBy set by the keytip. We also can't rely on only passing in the merged aria-describedBy to the keytipProps since not all items have keytips.

Instead there are two approaches done here to match the current syntax. In the splitButton, we continue to set aria-describedBy to the merged aria properties and include keytipAttributes['aria-describedby']. In the menu button and the anchor, we get a build error if we try to do the same thing saying that 'aria-describedby' is not a prop on keytipAttributes and instead we need to pass the merged aria-describedBy into the contents as a native prop. Since we also pass it as part of the keytip props with {...keytipAttributes}, if the aria-describedBy exists on the keytipAttributes it will override the other instance and properly set the merged aria-describedBy to be the ones we passed in and include the keytip spans. If it does not exist on the keytipAttributes, the passed in value will remain.

I have added an example of different context menu types with ariaDescriptions and verified they are read out by the screen reader when "Hear advanced detail" is selected.

Lastly, I'm not completely sure I made my change file correctly and don't know the proper tags to add. Essentially I would like this to go into Fabric 7 and have it pushed to Fabric 8 once the release is complete. This is an accessibility issue which we need to fix in Office so we don't want to wait until the release of V8

Focus areas to test

Contextual menus, keytips on contextual menus, screen reader

@SavannahBourgeois
Copy link
Collaborator Author

@jspurlin as FYI

@msft-github-bot
Copy link
Contributor

msft-github-bot commented Oct 29, 2020

Perf Analysis

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 879 879 5000
BaseButtonCompat mount 947 992 5000
Breadcrumb mount 43585 43095 5000
Checkbox mount 1609 1601 5000
CheckboxBase mount 1372 1376 5000
ChoiceGroup mount 4991 4990 5000
ComboBox mount 1002 1008 1000
CommandBar mount 10108 10179 1000
ContextualMenu mount 6127 6214 1000
DefaultButtonCompat mount 1207 1236 5000
DetailsRow mount 3848 3838 5000
DetailsRowFast mount 3870 3729 5000
DetailsRowNoStyles mount 3646 3538 5000
Dialog mount 1540 1556 1000
DocumentCardTitle mount 1792 1867 1000
Dropdown mount 3613 3608 5000
FocusTrapZone mount 1863 1878 5000
FocusZone mount 1784 1759 5000
IconButtonCompat mount 1834 1876 5000
Label mount 339 358 5000
Layer mount 1859 1916 5000
Link mount 472 494 5000
MenuButtonCompat mount 1571 1568 5000
MessageBar mount 2006 2051 5000
Nav mount 3418 3434 1000
OverflowSet mount 1073 1120 5000
Panel mount 1481 1524 1000
Persona mount 900 927 1000
Pivot mount 1455 1488 1000
PrimaryButtonCompat mount 1313 1412 5000
Rating mount 8074 8024 5000
SearchBox mount 1401 1393 5000
Shimmer mount 2745 2721 5000
Slider mount 1969 1952 5000
SpinButton mount 5204 5249 5000
Spinner mount 456 433 5000
SplitButtonCompat mount 3356 3327 5000
Stack mount 516 534 5000
StackWithIntrinsicChildren mount 1700 1635 5000
StackWithTextChildren mount 5114 5022 5000
SwatchColorPicker mount 10599 10652 5000
TagPicker mount 2847 2893 5000
TeachingBubble mount 11810 11839 5000
Text mount 458 444 5000
TextField mount 1448 1461 5000
ThemeProvider mount 1998 1959 5000
ThemeProvider virtual-rerender 686 683 5000
Toggle mount 873 831 5000
button mount 546 558 5000
buttonNative mount 106 108 5000

Perf Analysis (Fluent)

Perf comparison
Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🎯 Avatar.Fluent 0.49 0.55 0.89:1 2000 979
🦄 Button.Fluent 0.13 0.27 0.48:1 5000 665
🔧 Checkbox.Fluent 0.68 0.35 1.94:1 1000 678
🎯 Dialog.Fluent 0.17 0.24 0.71:1 5000 851
🔧 Dropdown.Fluent 3.1 0.45 6.89:1 1000 3095
🔧 Icon.Fluent 0.16 0.07 2.29:1 5000 821
🦄 Image.Fluent 0.09 0.14 0.64:1 5000 463
🔧 Slider.Fluent 1.73 0.48 3.6:1 1000 1733
🔧 Text.Fluent 0.09 0.03 3:1 5000 435
🦄 Tooltip.Fluent 0.12 0.95 0.13:1 5000 610

🔧 Needs work     🎯 On target     🦄 Amazing

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
ListNestedPerf.default 698 632 1.1:1
StatusMinimalPerf.default 871 796 1.09:1
FlexMinimalPerf.default 356 329 1.08:1
ReactionMinimalPerf.default 490 455 1.08:1
RefMinimalPerf.default 250 231 1.08:1
Text.Fluent 435 404 1.08:1
AccordionMinimalPerf.default 188 175 1.07:1
AnimationMinimalPerf.default 474 445 1.07:1
DividerMinimalPerf.default 455 427 1.07:1
SegmentMinimalPerf.default 436 407 1.07:1
TextAreaMinimalPerf.default 606 567 1.07:1
Icon.Fluent 821 766 1.07:1
AttachmentMinimalPerf.default 194 183 1.06:1
BoxMinimalPerf.default 442 422 1.05:1
ButtonSlotsPerf.default 669 635 1.05:1
LayoutMinimalPerf.default 479 458 1.05:1
ButtonMinimalPerf.default 206 198 1.04:1
FormMinimalPerf.default 516 498 1.04:1
InputMinimalPerf.default 1455 1400 1.04:1
LoaderMinimalPerf.default 834 803 1.04:1
PortalMinimalPerf.default 172 166 1.04:1
TableMinimalPerf.default 481 462 1.04:1
Avatar.Fluent 979 945 1.04:1
ImageMinimalPerf.default 467 453 1.03:1
ItemLayoutMinimalPerf.default 1459 1423 1.03:1
SkeletonMinimalPerf.default 514 498 1.03:1
TreeMinimalPerf.default 1004 978 1.03:1
Slider.Fluent 1733 1688 1.03:1
AlertMinimalPerf.default 356 349 1.02:1
ButtonUseCssNestingPerf.default 1234 1208 1.02:1
CarouselMinimalPerf.default 508 499 1.02:1
EmbedMinimalPerf.default 2135 2083 1.02:1
HeaderMinimalPerf.default 446 438 1.02:1
MenuButtonMinimalPerf.default 1772 1741 1.02:1
ProviderMinimalPerf.default 1122 1098 1.02:1
RadioGroupMinimalPerf.default 519 508 1.02:1
TooltipMinimalPerf.default 924 909 1.02:1
Button.Fluent 665 649 1.02:1
Dropdown.Fluent 3095 3049 1.02:1
AvatarMinimalPerf.default 525 520 1.01:1
ButtonUseCssPerf.default 914 906 1.01:1
CardMinimalPerf.default 639 633 1.01:1
ChatMinimalPerf.default 717 707 1.01:1
DropdownManyItemsPerf.default 858 850 1.01:1
GridMinimalPerf.default 417 412 1.01:1
MenuMinimalPerf.default 990 978 1.01:1
PopupMinimalPerf.default 755 747 1.01:1
SliderMinimalPerf.default 1723 1712 1.01:1
SplitButtonMinimalPerf.default 4198 4136 1.01:1
TableManyItemsPerf.default 2475 2444 1.01:1
TextMinimalPerf.default 426 422 1.01:1
ToolbarMinimalPerf.default 1047 1039 1.01:1
Tooltip.Fluent 610 605 1.01:1
AttachmentSlotsPerf.default 1257 1254 1:1
ChatDuplicateMessagesPerf.default 464 464 1:1
ChatWithPopoverPerf.default 512 512 1:1
DropdownMinimalPerf.default 3113 3101 1:1
HeaderSlotsPerf.default 906 906 1:1
TreeWith60ListItems.default 233 234 1:1
VideoMinimalPerf.default 708 705 1:1
Checkbox.Fluent 678 675 1:1
CustomToolbarPrototype.default 4153 4186 0.99:1
Dialog.Fluent 851 857 0.99:1
ButtonOverridesMissPerf.default 1848 1885 0.98:1
DialogMinimalPerf.default 879 893 0.98:1
LabelMinimalPerf.default 497 507 0.98:1
IconMinimalPerf.default 750 769 0.98:1
CheckboxMinimalPerf.default 2963 3048 0.97:1
ListWith60ListItems.default 1005 1041 0.97:1
Image.Fluent 463 479 0.97:1
ListCommonPerf.default 736 766 0.96:1
ProviderMergeThemesPerf.default 2039 2114 0.96:1
ListMinimalPerf.default 548 583 0.94:1

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 29, 2020

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 58dc09b:

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

@size-auditor
Copy link

size-auditor bot commented Oct 29, 2020

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react fluentui-react-ContextualMenu 142.927 kB 144.021 kB ExceedsTolerance     1.094 kB
office-ui-fabric-react fluentui-react-Dialog 196.102 kB 197.103 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-Grid 166.511 kB 167.512 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-DocumentCard 200.2 kB 201.201 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-SearchBox 172.966 kB 173.967 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-Facepile 194.926 kB 195.927 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-SelectedItemsList 214.278 kB 215.279 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-Pickers 267.859 kB 268.86 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-FloatingPicker 224.651 kB 225.652 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-SpinButton 179.03 kB 180.031 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-CommandBar 186.178 kB 187.179 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-ComboBox 230.307 kB 231.308 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-Dropdown 216.313 kB 217.314 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-Panel 185.662 kB 186.663 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-SwatchColorPicker 176.024 kB 177.025 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-Nav 174.486 kB 175.487 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-Breadcrumb 184.563 kB 185.564 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-MessageBar 173.879 kB 174.88 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-TeachingBubble 189.926 kB 190.927 kB ExceedsBaseline     1.001 kB
office-ui-fabric-react fluentui-react-Pivot 174.392 kB 175.39 kB ExceedsBaseline     998 bytes

ExceedsTolerance Over Tolerance (1024 B) ExceedsBaseline Over Baseline BelowBaseline Below Baseline New New Deleted  Removed 1 kB = 1000 B

Baseline commit: f247986022979128560a07502bbe434093324c36 (build)

@SavannahBourgeois
Copy link
Collaborator Author

@joschect can you take a look some time this week please? We would like to fix our accessibility issue in office. Thanks!

@joschect joschect merged commit 4270b4a into microsoft:master Nov 12, 2020
@msft-github-bot
Copy link
Contributor

🎉@fluentui/react-internal@v8.0.0-beta.11 has been released which incorporates this pull request.:tada:

Handy links:

SethDonohue pushed a commit to SethDonohue/fluentui that referenced this pull request Nov 23, 2020
* Add support for ariaDescription in contextual menu items

* Change files

* Fix lint error

* fix another lint error

Co-authored-by: Savannah Bourgeois <sareiff@microsoft.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.

Allow ariaDescription as a prop on IContextualMenuItem
4 participants