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

fix(Dropdown): make clearIndicator tabbable in non-search #12684

Merged
merged 5 commits into from
Apr 22, 2020
Merged

fix(Dropdown): make clearIndicator tabbable in non-search #12684

merged 5 commits into from
Apr 22, 2020

Conversation

silviuaavram
Copy link
Contributor

@silviuaavram silviuaavram commented Apr 14, 2020

Pull request checklist

  • Addresses an existing issue: Fixes #0000
  • Include a change request file using $ yarn change

Description of changes

To give users the ability to clear the selection by keyboard in a select dropdown we are making the indicator tabbable.
We are keeping it only clickable in a combobox context since clearing can be achievable by Escape.

Focus areas to test

(optional)

Microsoft Reviewers: Open in CodeFlow

@size-auditor
Copy link

size-auditor bot commented Apr 14, 2020

Asset size changes

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

Baseline commit: 11e1db9534bdfc9e0758cca2ee1edba6cacf2ec7 (build)

@msft-github-bot
Copy link
Contributor

msft-github-bot commented Apr 14, 2020

Perf Analysis

No significant results to display.

All results

Scenario Master Ticks PR Ticks Iterations Status
BaseButton 767 675 5000
Checkbox 1361 1294 5000
CheckboxBase 1091 1120 5000
ChoiceGroup 4256 4485 5000
ComboBox 725 764 1000
CommandBar 6174 5994 1000
ContextualMenu 11105 10059 1000
DefaultButton 900 911 5000
DetailsRow 2869 2921 5000
DetailsRow (fast icons) 2920 2919 5000
DetailsRow without styles 2837 2721 5000
Dialog 1257 1272 1000
DocumentCardTitle with truncation 1310 1257 1000
Dropdown 2053 2160 5000
FocusZone 1343 1316 5000
IconButton 1435 1524 5000
Label 241 269 5000
Link 394 384 5000
MenuButton 1228 1262 5000
Nav 2804 2634 1000
Panel 1181 1195 1000
Persona 760 730 1000
Pivot 1089 1215 1000
PrimaryButton 1020 1036 5000
SearchBox 1116 1105 5000
Slider 1280 1262 5000
Spinner 316 294 5000
SplitButton 2577 2580 5000
Stack 396 402 5000
Stack with Intrinsic children 1006 913 5000
Stack with Text children 3605 3655 5000
TagPicker 2364 2330 5000
Text 306 291 5000
TextField 1184 1178 5000
Toggle 741 745 5000
button 51 47 5000

Perf Analysis (Fluent)

Perf comparison
Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🎯 Avatar.Fluent 0.42 0.43 0.98:1 2000 836
🦄 Button.Fluent 0.1 0.15 0.67:1 5000 492
🔧 Checkbox.Fluent 0.56 0.3 1.87:1 1000 562
🔧 Dialog.Fluent 0.31 0.17 1.82:1 5000 1543
🔧 Dropdown.Fluent 2.85 0.37 7.7:1 1000 2853
🔧 Icon.Fluent 0.13 0.05 2.6:1 5000 657
🎯 Image.Fluent 0.07 0.09 0.78:1 5000 373
🔧 Slider.Fluent 1.2 0.27 4.44:1 1000 1200
🔧 Text.Fluent 0.07 0.02 3.5:1 5000 369
🦄 Tooltip.Fluent 0.08 11.71 0.01:1 5000 390

🔧 Needs work     🎯 On target     🦄 Amazing

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
ChatMinimalPerf.default 596 528 1.13:1
RadioGroupMinimalPerf.default 547 492 1.11:1
Text.Fluent 369 332 1.11:1
CardMinimalPerf.default 571 526 1.09:1
Button.Fluent 492 451 1.09:1
ChatWithPopoverPerf.default 490 455 1.08:1
HeaderSlotsPerf.default 1510 1414 1.07:1
Dropdown.Fluent 2853 2670 1.07:1
DialogMinimalPerf.default 1581 1489 1.06:1
Checkbox.Fluent 562 529 1.06:1
FormMinimalPerf.default 682 650 1.05:1
HierarchicalTreeMinimalPerf.default 901 859 1.05:1
LabelMinimalPerf.default 393 374 1.05:1
ListCommonPerf.default 920 873 1.05:1
MenuButtonMinimalPerf.default 1375 1307 1.05:1
TextMinimalPerf.default 336 319 1.05:1
TreeMinimalPerf.default 1037 989 1.05:1
Dialog.Fluent 1543 1465 1.05:1
AvatarMinimalPerf.default 452 436 1.04:1
IconMinimalPerf.default 629 607 1.04:1
AlertMinimalPerf.default 273 266 1.03:1
RefMinimalPerf.default 191 186 1.03:1
CustomToolbarPrototype.default 2927 2849 1.03:1
AttachmentMinimalPerf.default 125 123 1.02:1
ImageMinimalPerf.default 338 331 1.02:1
ProviderMinimalPerf.default 515 506 1.02:1
TooltipMinimalPerf.default 623 610 1.02:1
Image.Fluent 373 367 1.02:1
DividerMinimalPerf.default 656 649 1.01:1
DropdownMinimalPerf.default 2746 2713 1.01:1
LayoutMinimalPerf.default 524 518 1.01:1
PopupMinimalPerf.default 197 196 1.01:1
PortalMinimalPerf.default 265 263 1.01:1
ToolbarMinimalPerf.default 889 876 1.01:1
VideoMinimalPerf.default 716 707 1.01:1
Icon.Fluent 657 652 1.01:1
ButtonSlotsPerf.default 546 546 1:1
GridMinimalPerf.default 594 592 1:1
ListWith60ListItems.default 1015 1018 1:1
LoaderMinimalPerf.default 663 661 1:1
AttachmentSlotsPerf.default 982 991 0.99:1
BoxMinimalPerf.default 323 325 0.99:1
ItemLayoutMinimalPerf.default 1511 1529 0.99:1
MenuMinimalPerf.default 1533 1556 0.99:1
SegmentMinimalPerf.default 886 895 0.99:1
SliderMinimalPerf.default 1125 1142 0.99:1
Avatar.Fluent 836 843 0.99:1
AnimationMinimalPerf.default 587 598 0.98:1
ListMinimalPerf.default 429 439 0.98:1
ListNestedPerf.default 785 801 0.98:1
SplitButtonMinimalPerf.default 3236 3287 0.98:1
CarouselMinimalPerf.default 511 525 0.97:1
DropdownManyItemsPerf.default 1146 1178 0.97:1
EmbedMinimalPerf.default 3498 3620 0.97:1
FlexMinimalPerf.default 318 328 0.97:1
HeaderMinimalPerf.default 446 459 0.97:1
ProviderMergeThemesPerf.default 1239 1279 0.97:1
TextAreaMinimalPerf.default 2386 2451 0.97:1
Slider.Fluent 1200 1231 0.97:1
Tooltip.Fluent 390 402 0.97:1
ChatDuplicateMessagesPerf.default 343 356 0.96:1
CheckboxMinimalPerf.default 2426 2522 0.96:1
InputMinimalPerf.default 787 820 0.96:1
StatusMinimalPerf.default 635 664 0.96:1
TreeWith60ListItems.default 163 169 0.96:1
AccordionMinimalPerf.default 168 176 0.95:1
TableMinimalPerf.default 516 551 0.94:1
ButtonMinimalPerf.default 150 162 0.93:1
ReactionMinimalPerf.default 1574 1693 0.93:1

@@ -506,6 +506,7 @@ class Dropdown extends AutoControlledComponent<WithAsProp<DropdownProps>, Dropdo
className: Dropdown.slotClassNames.clearIndicator,
styles: styles.clearIndicator,
accessibility: indicatorBehavior,
...(!search && { tabIndex: 0 }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move this logic into indicatorBehavior to be more consistent with other components? Right now we work with tabbIndex mostly in Behaviors only (apart from Dropdown and RadioGroup components)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should leave indicatorBehavior as it is. Based on this comment and the other one maybe we should create a new behavior, clearIndicatorBehavior or something, that will be tabbable, not have any aria-hidden and instead have aria-label.

@jurokapsiar @kolaps33 what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand it correctly with this change there will be element which will have:
role: img,
aria-hidden: true
tabIndex: 0

What doesn't looks reasonable from my point of view.

I think would be better if clear indicator icon element has:
role: button
tabIndex: 0

And in this case it would make sense to put in into new behavior.

Copy link
Contributor

@kolaps33 kolaps33 Apr 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even wouldn't be there more clear way to use icon only button?
<Button icon="icon-close" text iconOnly title="Close" />
just asking as I don't know the code well if it is possible or not... :)

@@ -506,6 +506,7 @@ class Dropdown extends AutoControlledComponent<WithAsProp<DropdownProps>, Dropdo
className: Dropdown.slotClassNames.clearIndicator,
styles: styles.clearIndicator,
accessibility: indicatorBehavior,
...(!search && { tabIndex: 0 }),
Copy link
Contributor

@pompomon pompomon Apr 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add some user-defined label, since the clearIndicator would be tabbable, but it won't have any aria-label to indicate it's purpose to screen-reader users. And also here there might be a question whether or not we should keep 'aria-hidden=true' and 'role=img' from IndicatorBehavior, when we make clearIndicator tabbable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to create a separate behavior for clearIndicator

/**
* @description
* Indicator is usually only visual representation and therefore is hidden from screen readers, unless 'aria-label' property is provided.
* Adds attribute 'tabIndex=-1' to 'root' slot if 'search' property is false. Does not set the attribute otherwise.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Adds attribute 'tabIndex=-1' to 'root' slot if 'search' property is false. Does not set the attribute otherwise.
* Adds attribute 'tabIndex=0' to 'root' slot if 'search' property is false. Does not set the attribute otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And shouldn't it be in the @specification part?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

const dropdownClearIndicatorBehavior: Accessibility<DropdownClearIndicatorBehaviorProps> = props => ({
attributes: {
root: {
role: 'button',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about the adding condition(!props.search) for the role as well?
I would propose it, because even element has no tabIndex, but if it is button for example JAWS can navigate there with Virtual cursor
I did testing with this example:
https://codesandbox.io/s/fluent-ui-example-2plsz?file=/example.js

@silviuaavram silviuaavram merged commit 9661499 into microsoft:master Apr 22, 2020
@silviuaavram silviuaavram deleted the fix/dropdown-select-clearable branch April 22, 2020 08:29
DuanShaolong pushed a commit to DuanShaolong/fluentui that referenced this pull request Apr 27, 2020
…12684)

* make clearIndicator tabbable in non search

* also add role button

* fix unit test

* changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fluent UI react-northstar (v0) Work related to Fluent UI V0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants