googlemaps / googlemaps/android-maps-compose

Clustering: Missing contentDescription on the clustering pins

Open
#683 3 comments 1 reaction 0 assignees View on GitHub
priority: p1 type: bug
Dominant language
Kotlin
Stars
1.3k
Forks
181
Avg merge
2d 23h
Merged PRs (30d)
18

Description

Hi,

I am missing `contentDescription` on the clustering pins.
It's an issue only for the clustering pins, as `contentDescription` works fine for the non-clustering pins.

### Environment details

1. OS type and version:
Android 15 (Google Pixel 7 Pro emulator on Windows 10)
2. Library and version:
`com.google.maps.android:maps-compose:6.4.4`
`com.google.maps.android:maps-compose-utils:6.4.4`
compose BOM `2024.10.01`

### Steps to reproduce

1. Add clustering pins through the Clustering function. I don't believe it really matters how you do this, but you can check our setup below
2. Set `contentDescription` on your clustering pins
3. Run the app and view pins on map
4. Export uiautomator xml dump
`adb shell uiautomator dump /sdcard/ui.xml`
`adb pull /sdcard/ui.xml "exported_test_tags.xml"`
5. Check the exported xml for `content-desc` values of the clustering pins

#### App screenshot for the uiautomator dump
![Image](https://github.com/user-attachments/assets/c07cb79a-fc4f-4e15-9b3f-3ebb4510284c)

#### Slice of the uiautomator dump I got for the attached screenshot (trimmed some unnecessary tags & data)
```
























```

### The missing contentDescription part
I expected to see the clustering pins with their correct `content-desc` tag value in the xml.
`content-desc="marker_generic_unselected_ChIJx0ZL3KwEdkgRbqnmC8H0RA8"`
`content-desc="marker_generic_unselected_ChIJFZCSWqYEdkgRrIou3nanh70"`

But they all have `content-desc="Map Marker"`. They are in the xml dump, but outside of the the "Google Map" view element.
This causes our automated test on Appium to break, as they can't find the pins to "click on them".
Any idea on how to fix this issue? Unfortunately the "Map Marker" value seems to be hardcoded.

I would like to see something like this, in the xml dump
```


```

### Code example
#### GoogleMaps Clustering setup
```
GoogleMap(
mergeDescendants = false // it's actually a default value, but it's important to mention this param
) {
val clusterManager = rememberClusterManager()
val renderer = rememberClusterRenderer(
clusterContent = { Cluster(it) },
clusterItemContent = { ClusterItem(it) },
clusterManager = clusterManager,
)

clusterManager?.renderer = renderer

Clustering(
items = pins.toClusterPins(),
clusterManager = clusterManager,
)
}

// We are creating renderer ourselfs so that we can use NonHierarchicalViewBasedAlgorithm algorithm for the cluster manager
```

#### Clustering pins composable
```
@Composable
fun ClusterItem(pin: ClusterPinResource) {
Image(
bitmap = pin.icon,
contentDescription = pin.testTag,
)
}
```

#### Also tried this composable
```
@Composable
fun ClusterItem(pin: ClusterPinResource) {
Box(
modifier = Modifier
.wrapContentSize()
.semantics { contentDescription = pin.testTag }
.testTag(pin.testTag)
) { /* some content */ }
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.