Skip to content

Commit 37df9c0

Browse files
committed
fix(android): fold only a visible Compose role node, and cover interactive captures
1 parent b6ab753 commit 37df9c0

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎packages/platform-android/src/__tests__/ui-hierarchy-builder.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,16 @@ test('publishes a Compose role node as its clickable parent and keeps real child
115115
visible-to-user="true" />
116116
</node>
117117
<node class="android.widget.Button" bounds="[53,2250][1027,2370]" visible-to-user="true" />
118+
<node class="android.view.View" resource-id="hidden-role-row"
119+
bounds="[53,2380][1027,2390]" clickable="true" visible-to-user="true">
120+
<node class="android.widget.Button" bounds="[53,2380][1027,2390]"
121+
visible-to-user="false" />
122+
</node>
118123
</node>
119124
</hierarchy>`);
120125

121126
const { nodes } = buildUiHierarchySnapshot(tree, undefined, {});
127+
const interactive = buildUiHierarchySnapshot(tree, undefined, { interactiveOnly: true }).nodes;
122128
const published = nodes
123129
.filter((node) => node.parentIndex !== undefined)
124130
.map((node) => `${node.type} ${node.identifier ?? ''}`.trim());
@@ -131,5 +137,9 @@ test('publishes a Compose role node as its clickable parent and keeps real child
131137
'android.view.View legacy-row',
132138
'android.widget.CheckBox',
133139
'android.widget.Button',
140+
'android.view.View hidden-role-row',
134141
]);
142+
expect(interactive.find((node) => node.identifier === 'continue-with-email')?.type).toBe(
143+
'android.widget.Button',
144+
);
135145
});

‎packages/platform-android/src/ui-hierarchy-compose-role.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function isComposeRoleNode(child: AndroidNode, parent: AndroidNode): boolean {
2626
return (
2727
COMPOSE_ROLE_CLASS_NAMES.has(child.type?.toLowerCase() ?? '') &&
2828
child.children.length === 0 &&
29+
child.visibleToUser !== false &&
2930
!isAgentTarget(child) &&
3031
!child.label &&
3132
!child.identifier &&

0 commit comments

Comments
 (0)