mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(hierarchy): derive package from resource-id prefix
The Android sidecar omits an explicit package attribute, so the verifier's package scope filter was a no-op and the keyboard still leaked into targets. Native nodes carry their package as the resource-id prefix; derive it there when the attribute is absent. Compose testTags are colon-less and stay empty, keeping them in scope.
This commit is contained in:
1 parent
6d3561bf6c
commit
8401ae908f
1 file changed
+12
@@ -206,6 +206,18 @@ func elementFromNode(node *treeNodeJSON) *Element {
|
||||
}
|
||||
element.Class = attrs["class"]
|
||||
element.Package = attrs["package"]
|
||||
if element.Package == "" {
|
||||
// Android omits an explicit package attribute, but native views carry
|
||||
// it as the resource-id prefix (`com.android.systemui:id/...`). Compose
|
||||
// testTags are colon-less and leave the package empty, which keeps them
|
||||
// in scope. This lets target selection tell the app apart from the soft
|
||||
// keyboard and system UI.
|
||||
if resourceID := attrs["resource-id"]; resourceID != "" {
|
||||
if colon := strings.IndexByte(resourceID, ':'); colon > 0 {
|
||||
element.Package = resourceID[:colon]
|
||||
}
|
||||
}
|
||||
}
|
||||
element.Screen = attrs["sanderling-screen"]
|
||||
|
||||
if node.Clickable != nil {
|
||||
|
||||
Reference in new issue
Block a user