Skip to content

feat(picker): picker column is easier to select with assistive technology - #29371

Merged
liamdebeasi merged 30 commits into
feature-8.1from
FW-1891
Apr 24, 2024
Merged

feat(picker): picker column is easier to select with assistive technology#29371
liamdebeasi merged 30 commits into
feature-8.1from
FW-1891

Conversation

@liamdebeasi

@liamdebeasiliamdebeasi commented Apr 22, 2024

Copy link
Copy Markdown
Contributor

Issue number: resolves#25221


What is the current behavior?

The wheel picker is hard to use with screen readers because users need to manually swipe over every option. Not only is this tedious, it also means it's impossible to move between columns/leave the picker by swiping only because the act of swiping selects a value.

What is the new behavior?

We did investigations into how native handles the wheel picker, and both iOS and Android do it differently. Unfortunately, neither of those patterns can be implemented exactly using web tech (at least not without a lot of brittle/hacky code).

As a result, we settled on a solution that follows web accessibility best practices and addresses the original issue:

  • Each picker column now renders an invisible element. This element receives focus and handles keyboard navigation. This element also has role="slider" which means that screen readers should synthesize keyboard events when swiping. This allows us to resolve the original issue. Users can also double tap to slide up/down to adjust values instead.

Note: Chrome currently does not synthesize keyboard events. However, this is something that could be fixed in the future (since Chrome is not following the spec right now). Android users can double tap to slide up/down in the meantime.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev build: 8.0.0-dev.11713893672.15a2b23e

Reviews: Please test this on iOS and Android!

I recommend testing on src/components/datetime/test/prefer-wheel since it lets you the core functionality as well as the datetime-specific integrations (the aria labels)

Docs PR: ionic-team/ionic-docs#3612

@vercel

vercelBot commented Apr 22, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

NameStatusPreviewCommentsUpdated (UTC)
ionic-framework✅ Ready (Inspect)Visit Preview💬 Add feedbackApr 24, 2024 2:43pm

newOption = this.findPreviousOption();
break;
case 'PageUp':
newOption = this.findPreviousOption(5);

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

A stride of 5 was based on how browsers handle PageUp/PageDown in scroll snapping containers

Comment on lines -476 to -477
if (!this.disabled && option.disabled) {
return false;

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

My understanding is this if statement had more checks than it needed to. According to the comment, the picker column's disabled state has no bearing on whether or not an option should be rendered as active, so we don't need to check it.

@liamdebeasiliamdebeasi changed the title Fw 1891fix(picker): make picker columns easier to select with assistive technologyApr 22, 2024
}

connectedCallback() {
this.ariaLabel = this.el.getAttribute('aria-label') ?? 'Select a value';

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I could be convinced to not have a default value here since the label isn't super helpful. However, I was concerned about breaking the existing experience since not using an aria-label on the slider role could cause tools such as Axe to start failing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think a label is better than no label here. It is also incredibly straightforward for developers to customize it.

@liamdebeasi
liamdebeasi marked this pull request as ready for review April 23, 2024 18:16
@liamdebeasi
liamdebeasi requested a review from a team as a code ownerApril 23, 2024 18:16
@liamdebeasi
liamdebeasi changed the base branch from main to feature-8.1April 23, 2024 20:01
@github-actionsgithub-actionsBot added package: angular @ionic/angular package package: vue @ionic/vue package package: react @ionic/react package labels Apr 23, 2024

@sean-perkinssean-perkins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Moving into device testing next, small suggestion on a type adjustment for stricter types.

Comment threadcore/src/components/picker-column/picker-column.tsx Outdated
Comment threadcore/src/components/picker-column/picker-column.tsx Outdated
}

connectedCallback() {
this.ariaLabel = this.el.getAttribute('aria-label') ?? 'Select a value';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think a label is better than no label here. It is also incredibly straightforward for developers to customize it.


return (
<ion-picker-column
aria-label="Select a day period"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm ok with the naming here.

liamdebeasiand others added 2 commits April 24, 2024 10:39
Co-authored-by: Sean Perkins <13732623+sean-perkins@users.noreply.github.com>
@liamdebeasiliamdebeasi changed the title fix(picker): picker column is easier to select with assistive technologyfeat(picker): picker column is easier to select with assistive technologyApr 24, 2024
@liamdebeasi
liamdebeasi merged commit e38e2e4 into feature-8.1Apr 24, 2024
@liamdebeasi
liamdebeasi deleted the FW-1891 branch April 24, 2024 20:25
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core@ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: datetime month/year picker is hard to use with screen readers

2 participants

@liamdebeasi@sean-perkins