Add focus_order: keyboard tab sequence, WCAG focus-order audit, set-focus#400
Merged
Conversation
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.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 39 |
| Duplication | 0 |
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Why
Nothing in the toolkit reasoned about keyboard navigation — only mouse coordinates and element values.
focus_orderadds the keyboard layer:is_interactive_role— is a role one that normally takes keyboard focustab_order— focusable elements in the orderTabwill 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 (UIASetFocus)This completes the native-UI HIGH lane (after
control_patterns,ax_text,ax_tree_walk).Design
AccessibilityElementlists.tab_orderreuseselement_parse.reading_orderfor row banding andis_interactive_rolereusesax_tree_walk.humanize_role— no duplicated logic.focus_controldispatches the injectableaccessibility.backends.get_backend()seam; the realSetFocuslives in the Windows backend (ABC default raisesAccessibilityNotAvailableError).__all__→AC_tab_order/AC_audit_focus_order/AC_focus_control→ac_*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), thefocus_controldevice seam + unsupported-backend error via a fake backend, the executor_tab_order/_audit_focus_orderpaths, and 5-layer wiring. 32 passed alongside the sibling native-UI batches.