Skip to content

Commit 77e8045

Browse files
thymikeeclaude
andcommitted
refactor(ios): read both focus keys as BOOLs in the private-AX bridge
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 63e556c commit 77e8045

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ + (NSArray *)snapshotAttributes
360360
{
361361
// The mapper expands keypaths with extra attributes that are disproportionately expensive for
362362
// the AX server to compute on large trees. Keep only what is consumed here.
363+
// `hasKeyboardFocus` is not requested: the mapper adds no attribute for it, and the snapshot
364+
// answers it anyway (#4112).
363365
return [self attributesForKeyPaths:@[
364366
@"elementType",
365367
@"identifier",
@@ -752,8 +754,9 @@ + (nullable NSMutableDictionary *)dictionaryForSnapshot:(id)snapshot
752754
result[@"frame"] = [self frameValueForSnapshot:snapshot];
753755
result[@"enabled"] = [self boolNumberForKey:@"enabled" snapshot:snapshot defaultValue:YES];
754756
result[@"selected"] = [self boolNumberForKey:@"selected" snapshot:snapshot defaultValue:NO];
755-
result[@"focused"] = @([[self boolNumberForKey:@"hasKeyboardFocus" snapshot:snapshot defaultValue:NO] boolValue]
756-
|| [[self boolNumberForKey:@"hasFocus" snapshot:snapshot defaultValue:NO] boolValue]);
757+
BOOL keyboardFocused = [[self boolNumberForKey:@"hasKeyboardFocus" snapshot:snapshot defaultValue:NO] boolValue];
758+
BOOL engineFocused = [[self boolNumberForKey:@"hasFocus" snapshot:snapshot defaultValue:NO] boolValue];
759+
result[@"focused"] = @(keyboardFocused || engineFocused);
757760

758761
NSMutableArray *children = [NSMutableArray array];
759762
if (depth < maxDepth) {

0 commit comments

Comments
 (0)