Skip to content

fix: report keyboard focus from the snapshot's hasKeyboardFocus, so the Email field reports focus too - #104

Merged
gmegidish merged 2 commits into
mainfrom
fix/email-field-focus
Oct 15, 2026
Merged

gmegidish merged 2 commits into
mainfrom
fix/email-field-focus

Conversation

@gmegidish

@gmegidish gmegidish commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Problem

After tapping the Email field in Milliways' Edit Profile screen, the field is focused (cursor and email keyboard shown), but dumpUI marks no element as focused. Display name and Phone work.

The dump found the focused element with a separate hasKeyboardFocus == true query, then marked the node whose frame was exactly equal. For Email the two frames differ only in floating-point rounding, so nothing matched:

Y Height
focus query 239.33333333333334 21.99999999999997
Email node in the snapshot 239.33333333333331 22.0

Frame matching could also mark two nodes that share a rect, such as a text field and its container.

Fix

Each XCTest snapshot object already carries the private hasKeyboardFocus property. dictionaryRepresentation leaves it out, so elementHierarchy now walks the snapshot objects alongside the built tree and copies it onto the matching node.

  • No frame matching, so no rounding problem and no ambiguity between nodes that share a rect.
  • The separate query is gone, so the dump makes one pass over the accessibility tree instead of two. I didn't time it.
  • Every dump path goes through elementHierarchy (fallbacks, keyboard, alerts, status bars), so they all report focus.
  • It checks responds(to:) before reading the private property, so if a future Xcode drops it, focus just isn't reported and the agent doesn't crash.

Test plan

  • On the iPhone 17 Pro simulator, tapping each Edit Profile field marks exactly that TextField as focused, and nothing is focused before any tap.
  • Milliways' mobilewright conformance tests isFocused (Email) and toBeFocused (Phone) pass.
  • make lint reports no new violations in the changed lines.
  • Check on a real device.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 8f745b8c-2b3f-4a11-80a6-b960f00616d0
📥 Commits

Reviewing files that changed from the base of the PR and between 6a204d8 and 3683643.

📒 Files selected for processing: 1
  • DeviceKitTests/JSONRPC/Handlers/DumpUI.swift
💤 Files with no reviewable changes: 1
  • DeviceKitTests/JSONRPC/Handlers/DumpUI.swift

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.

Walkthrough

Keyboard focus marking now reads hasKeyboardFocus from snapshot objects and applies it to the hierarchy. The hierarchy builder applies focus before resolving nested-window offsets. Child recursion occurs only when the snapshot and hierarchy child counts match. The separate focused-element frame query and frame-matching helper were removed.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 36836

No actionable issue is established for the snapshot-based focus change. It is ready for normal merge checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: reporting keyboard focus from the snapshot's hasKeyboardFocus property so the Email field reports focus.
Description check Passed The description explains the reported focus-matching problem, the snapshot-based fix, affected behavior, and test results. It is directly related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@gmegidish
gmegidish force-pushed the fix/email-field-focus branch from 6a204d8 to 3683643 Compare October 15, 2026 20:16
@gmegidish
gmegidish merged commit f986d1d into main Oct 15, 2026
3 checks passed
@gmegidish
gmegidish deleted the fix/email-field-focus branch October 15, 2026 20:22
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