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(CQ-4295097): Accessibility - Spectrum SelectList user is not able to select next group with keyboard #127

Merged
merged 5 commits into from
Oct 19, 2020

Conversation

majornista
Copy link
Collaborator

Description

CQ-4295097 refactor _tabTarget setter and _resetTabTarget method

With SelectList groups only one item should receive focus at a time.

When resetting tabTarget, prioritized selected items over selectable items, but prioritize the last focused item over the first of the items in the array.

In Select component, we _resetTabTarget before the list opens, prioritizing the first selected item over the first selectable item.

Related Issue

#124 and https://jira.corp.adobe.com/browse/CQ-4295097

Motivation and Context

Correct behavior of a select list with option groups, by ensuring that only one item in the select list is tabbable at a time.

How Has This Been Tested?

Behavior has been tested in example documents for SelectList and Select.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

…select next group with keyboard

CQ-4295097 refactor _tabTarget setter and _resetTabTarget method

With SelectList groups only one item should receive focus at a time.

When resetting tabTarget, prioritized selected items over selectable items, but prioritize the last focused item over the first of the items in the array.

In Select component, we _resetTabTarget before the list opens, prioritizing the first selected item over the first selectable item.
@majornista
Copy link
Collaborator Author

@icaraps and @hameed87 This PR supersedes #124, combining changes from #124 and hameed87#1 into a single commit.

…extSelectable

Fixes TabList unit test failures.
@majornista
Copy link
Collaborator Author

@indra2gurjar, @icaraps and @hameed87

@icaraps
Copy link
Contributor

icaraps commented Sep 9, 2020

@majornista Can you please add a test case ?

@majornista majornista changed the title CQ-4295097 : Accessibility - Spectrum SelectList user is not able to select next group with keyboard fix(CQ-4295097): Accessibility - Spectrum SelectList user is not able to select next group with keyboard Oct 8, 2020
if (items.length > 0) {
items[0].focus();
const firstFocusable = items.find(item => item.tabIndex === 0);
(firstFocusable || items[0]).focus();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have this check item.tabIndex === 0 ?
What if the first item is button or anchorlink which are focusable but don't require tabindex=0?
the itemSelector at L-68 has 'button[is="coral-buttonlist-item"], a[is="coral-anchorlist-item"]'

Shouldn't we fix the same at _focusFirstItem and _focusLastItem etc.. which are called on key:home and key:end?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We want to prioritize the active or first selected item over the first item.

Copy link
Contributor

Choose a reason for hiding this comment

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

We are identifying firstFocusable by "item.tabIndex === 0" but items like buttons and anchorlinks won't have tabindex=0, they are by default focusable.
Lets say there are list items in following order .
button,
coral-seelct-list
coral-seelct-list

AFAIK here firstFocusable should be button, but button won;'t have tabindex=0.
So we will be focusing on second item 'coral-seelct-list' instead of button.

Please let me know if my understanding above isn't correct?

We want to prioritize the active or first selected item over the first item.

Do we have any other reliable way to detect last active/selected item ?

this._tabTarget = forceFirst ? items[0] : (items.find(item => item.tabIndex === 0) || items[0]);
this._tabTarget = forceFirst ? items[0] : (items.find(item => item.tabIndex === 0) || items[0]);

if (this.groups && this._groups.getAll().length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the _tabTarget be outside of groups?
If not then in the code below line-415 will always set the firstFocusable tabindex to -1 and we won't need to set it to 0 .

What is the intention of code below line-415?
AFAIK we want to set tabindex=-1 on all but first item across all groups, so only one item can be focused across all the groups.
Doesn't line-227 do the same thing? (set tabindex = -1 on all but one item)

@indra2gurjar indra2gurjar merged commit c80e629 into adobe:master Oct 19, 2020
github-actions bot pushed a commit that referenced this pull request Oct 19, 2020
## [4.10.6](v4.10.5...v4.10.6) (2020-10-19)

### Bug Fixes

* **CQ-4295097:** Accessibility - Spectrum SelectList user is not able to select next group with keyboard ([#127](#127)) ([c80e629](c80e629))
@github-actions
Copy link

🎉 This PR is included in version 4.10.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

3 participants