AccessKit / AccessKit/accesskit

It should not be an error for focus to point to a missing `NodeId`

Open
#587 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.5k
Forks
114
Avg merge
8h 25m
Merged PRs (30d)
28

Description

kas::Id is a (compressed) path, which allows tracking focus of unrealised (hidden) entries in a list while virtual scrolling. As such, it is not a bug for Kas's focus to point at a widget which doesn't exist. It is still possible to operate on such an Id by scrolling it back into view.

(No, Kas does not do this by keeping a copy of any widget in focus while scrolled out of view. It would be possible, but would require hacks in widget code, and imply that bugs in widget code can crash a UI when accessibility is enabled.)

Working around this

From the Kas side, I can check whether nav_focus points to a reachable widget (reverting to the root Id if not), but this is not equivalent to the AccessKit check since Kas may have dormant nodes not in the AccessKit tree. To accurately match the AccessKit check I'd need to store a copy of the tree.

The right way?

AccessKit already knows the root NodeId and tests focus; it would be much easier to revert to the root id in AccessKit.

Alternatively, AccessKit might actually try to support operations on unknown nodes. It could at least attempt Action::ScrollIntoView.

Or AccessKit could even keep the Node in its own tree as an orphan in this case. It is likely not wrong given that no more up-to-date representation of the Node is available. (Yes, I'm hesitant to suggest this. But, at least for Kas, it is more correct behaviour than panicking because focus does not point at a known Node.)

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 tracing AccessKit’s existing handling of the root and focus NodeId, especially the check for unknown nodes and the Action::ScrollIntoView path. Compare the proposed fallback, unknown-node support, and orphan-node alternatives before choosing a behavior. Done means a missing focus target no longer causes an erroneous failure and the selected behavior has coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
accessibility
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.