microsoft / microsoft/tabster

[Feature request]: options to prevent focus on body when restore

Open
#411 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
165
Forks
42
Avg merge
1d 11h
Merged PRs (30d)
9

Description

Problem description:

Open this example: https://stackblitz.com/edit/vitejs-vite-ytxz4e?file=package.json,src%2FApp.tsx&terminal=dev

  1. Turn on NVDA
  2. Focus on the 'Trigger' button, press enter key, the 'close' button should be visible and focused
  3. Switch NVDA to forms mode, press enter key again, notice the screen reader announces 'document':
image

This happens because the restore focus is async with a timeout. When switching the example to the react useEffect restore focus, this problem does not appear (and if setTimeout is used in react useEffect, it appears as well).

Possible solutions:

Option 1: provide the ability to synchronously focus on trigger - this was discussed in teams meeting and discarded because the trigger might not be focusable
Option 2: provide the ability to focus on dummy input with aria-hidden when focus moves back to trigger.

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 with the linked StackBlitz reproduction in src/App.tsx and reproduce the NVDA focus behavior described in the steps. Trace the asynchronous restore-focus path and determine which option is viable; done means the restored focus no longer moves the screen reader to the document while preserving behavior when the trigger is not focusable.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
accessibility
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.