medialize / medialize/ally.js

Making it possible to distinguish touch/mouse as source of focus

Open
#155 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

focus good first contribution improve
Dominant language
JavaScript
Stars
1.6k
Forks
82
PR merge metrics
No merged PRs in 30d

Description

Right now data-focus-source makes it possible to tell keyboard from pointer as the source of focus. We (@halmos and I) would like to be able to further distinguish different types of pointers. The use case is to be able to provide a thicker (or otherwise more visible) focus outline on touch, because you can't see what's under your finger.

In terms of how this gets exposed, I don't think we can change data-focus-source without breaking compatibility. So that would always reflect "pointer". But we can add a second data attribute, say data-pointer-type, that could contain touch/mouse/stylus/catpaw/headbang/etc.

In terms of implementation, just giving it a quick look I believe that https://github.com/medialize/ally.js/blob/master/src/observe/interaction-type.js could expose that distinction (since it knows what event it's reacting to) by incrementing/decrementing modality-specific counters in addition to the pointer one, and then that https://github.com/medialize/ally.js/blob/master/src/style/focus-source.js#L52 could simply make use of that information.

We're open to other approaches of course, this is just what we've thought up. If you're up for this, we'd be happy to file a PR.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading src/observe/interaction-type.js to see how event modality is tracked, then inspect src/style/focus-source.js around line 52. The change is complete when pointer input remains exposed as data-focus-source="pointer" while a separate attribute distinguishes touch, mouse, stylus, and other pointer types.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
accessibility, frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.