Skip to content

Add focus_order: keyboard tab sequence, WCAG focus-order audit, set-focus#400

Merged
JE-Chen merged 1 commit into
devfrom
feat/focus-order-batch
Jun 24, 2026
Merged

Add focus_order: keyboard tab sequence, WCAG focus-order audit, set-focus#400
JE-Chen merged 1 commit into
devfrom
feat/focus-order-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 24, 2026

Copy link
Copy Markdown
Member

Why

Nothing in the toolkit reasoned about keyboard navigation — only mouse coordinates and element values. focus_order adds the keyboard layer:

  • is_interactive_role — is a role one that normally takes keyboard focus
  • tab_order — focusable elements in the order Tab will visit them (reading order)
  • audit_focus_order — a WCAG 2.4.x focus-order report (the sequence + flagged problems, e.g. a focusable element with no visible area)
  • focus_control — set keyboard focus on a control (UIA SetFocus)

This completes the native-UI HIGH lane (after control_patterns, ax_text, ax_tree_walk).

Design

  • The first three are pure functions over AccessibilityElement lists. tab_order reuses element_parse.reading_order for row banding and is_interactive_role reuses ax_tree_walk.humanize_role — no duplicated logic.
  • focus_control dispatches the injectable accessibility.backends.get_backend() seam; the real SetFocus lives in the Windows backend (ABC default raises AccessibilityNotAvailableError).
  • 5 layers wired: core → facade __all__AC_tab_order / AC_audit_focus_order / AC_focus_controlac_* MCP tools (reads read-only, focus destructive) → Script Builder (Native UI). Qt-free import verified.

Tests

test/unit_test/headless/test_focus_order_batch.py — pure cases (role classification, tab-order filtering + reading order, zero-area audit flag, empty list), the focus_control device seam + unsupported-backend error via a fake backend, the executor _tab_order/_audit_focus_order paths, and 5-layer wiring. 32 passed alongside the sibling native-UI batches.

Nothing reasoned about keyboard navigation — only mouse coordinates and
element values. Add the keyboard layer: tab_order returns focusable
elements in the order Tab visits them (reading order), audit_focus_order
is a WCAG 2.4.x report flagging problems like zero-area focusable
elements, and focus_control sets keyboard focus via UIA SetFocus. The
pure parts reuse element_parse.reading_order and ax_tree_walk.humanize_role;
focus_control dispatches the injectable backend seam.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 39 complexity · 0 duplication

Metric Results
Complexity 39
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit 6f2f1b8 into dev Jun 24, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/focus-order-batch branch June 24, 2026 03:03
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant