Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

fix(carousel): pagination carousel - accessibility improvements #2278

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

kolaps33
Copy link
Collaborator

@kolaps33 kolaps33 commented Jan 28, 2020

Related carousel: Carousel with Pagination

In this PR are fixes related to the feedback which we got from Rekha when I tried fix application mode for the carousel with pagination.

Issue: Index numbers (1 of 4) are read twice as you down arrow through the carousel item.
Fix: add aria-hidden="true" on the text

2.1 Issue: The first and the last item in the carousel are not read when the prev/next button is pressed in browse mode.
2.2 #2224
Fix: moving focusing the next/previous paddle to generic function, which is call always, even when "onclick" is executed...

Issue: Should there be focus on the entire carousel control and the left/right buttons? Seems redundant and adds more keyboard stops
Fix: change the behavior that for carousel without the "tab" navigation there will be tabindex=-1 on CarouselItem

Issue: Carousel itself should have a label property defined. The roledescription is set to “Carousel” so label can be “Portrait collection” for this example
Fix: added prop aria-label to be able label the carousel

Issue: #2225
Fix: was decided that if reader will narrate "carousel" user will know how to use keyboard to rotate through the carousel
For this reason to narrate "carousel" in application mode was added additional props(role, aria-label,aria-roledescription) into "itemsContainer" in "carouselBehavior.ts".
Now there is role "group". After more testing could be change for "region". For me region was not narrating "carousel" in focus mode for NVDA.

Issue: Programmatically Prev/Next buttons are outside carousel container so it will likely confuse the user. Carousel container element should include all elements within carousel.
Fix: apply region only for "Carousel with Pagination", provide there proper label and roledescription. Fix is in "carouselBehavior.ts" for "root" slot.

@DustyTheBot
Copy link
Collaborator

DustyTheBot commented Jan 29, 2020

Warnings
⚠️ There are no updates provided to CHANGELOG. Ensure there are no publicly visible changes introduced by this PR.

Perf comparison

Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🔧 Avatar.Fluent 0.59 0.38 1.55:1 2000 1182
🔧 Button.Fluent 1.19 0.18 6.61:1 1000 1194
🔧 Checkbox.Fluent 1.37 0.28 4.89:1 1000 1370
🔧 Dialog.Fluent 0.32 0.17 1.88:1 5000 1597
🔧 Dropdown.Fluent 3.5 0.37 9.46:1 1000 3503
🔧 Icon.Fluent 0.24 0.03 8:1 5000 1224
🔧 Image.Fluent 0.1 0.07 1.43:1 5000 499
🔧 Slider.Fluent 2.2 0.39 5.64:1 1000 2200
🦄 Text.Fluent 0.06 0.23 0.26:1 5000 284
🦄 Tooltip.Fluent 0.42 18.32 0.02:1 5000 2096

🔧 Needs work     🎯 On target     🦄 Amazing

Generated by 🚫 dangerJS

@kolaps33 kolaps33 changed the title fix(carousel): accessibility improvements fix(carousel): pagination carousel - accessibility improvements Jan 29, 2020
@@ -390,6 +393,7 @@ class Carousel extends AutoControlledComponent<WithAsProp<CarouselProps>, Carous
})
) : (
<Text
aria-hidden="true"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand. If we are hiding this then what is the point in having it in the first place?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There was relevant complain that with virtual cursor navigation user hit the text twice.
I am hiding here the second text. First text appearance still stay in each tab/slide.

import { carouselItemBehavior } from '@fluentui/accessibility'

describe('carouselItemBehavior.ts', () => {
test('set tabIndex="0" when carousel has navigation and item is visible ', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

sets ... on root when ...

@@ -17,11 +25,18 @@ import * as keyboardKey from 'keyboard-key'
const carouselBehavior: Accessibility<CarouselBehaviorProps> = props => ({
attributes: {
root: {
role: 'region',
role: props.navigation ? undefined : 'region',
Copy link
Collaborator

Choose a reason for hiding this comment

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

if we say that we are not setting the attribute otherwise, shouldn't we destructure these 3 attributes? Because how we are doing it now we are adding either the value or undefined, any of these options meaning that we are setting a value.

Copy link
Collaborator

@silviuaavram silviuaavram Feb 20, 2020

Choose a reason for hiding this comment

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

also you can probably add the condition only once since it's the same one. something like

...(props.navigation && { role: 'region', 'aria-roledescription': props.ariaRoleDescription, 'aria-label': props.ariaLabel })

* Triggers 'arrowKeysNavigationStopPropagation' action with 'ArrowRight' or 'ArrowLeft' on 'root'.
*/
const carouselItemBehavior: Accessibility<CarouselItemProps> = props => ({
attributes: {
root: {
role: props.navigation ? 'tabpanel' : 'group',
'aria-hidden': props.active ? 'false' : 'true',
tabIndex: props.active ? 0 : -1,
tabIndex: props.navigation ? (props.active ? 0 : -1) : -1,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
tabIndex: props.navigation ? (props.active ? 0 : -1) : -1,
tabIndex: (props.navigation && props.active) ? 0 : -1,

},
itemsContainerWrapper: {
'aria-live': props.ariaLiveOn ? 'polite' : 'off',
},
itemsContainer: {
Copy link
Collaborator

@silviuaavram silviuaavram Feb 20, 2020

Choose a reason for hiding this comment

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

same comments as above here.

@silviuaavram
Copy link
Collaborator

Added a few comments @kolaps33

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants