-
Notifications
You must be signed in to change notification settings - Fork 170
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
- OS type and version:
Android 15 (Google Pixel 7 Pro emulator on Windows 10) - Library and version:
com.google.maps.android:maps-compose:6.4.4
com.google.maps.android:maps-compose-utils:6.4.4
compose BOM2024.10.01
Steps to reproduce
- 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
- Set
contentDescriptionon your clustering pins - Run the app and view pins on map
- Export uiautomator xml dump
adb shell uiautomator dump /sdcard/ui.xml
adb pull /sdcard/ui.xml "exported_test_tags.xml" - Check the exported xml for
content-descvalues of the clustering pins
App screenshot for the uiautomator dump
Slice of the uiautomator dump I got for the attached screenshot (trimmed some unnecessary tags & data)
<node index="0" resource-id="" class="androidx.compose.ui.viewinterop.ViewFactoryHolder" content-desc="">
<node index="0" resource-id="" class="android.widget.FrameLayout" content-desc="">
<node index="0" resource-id="com.example.app:id/maps_compose_nodraw_container_view" class="android.view.ViewGroup" content-desc="">
<node index="0" resource-id="" class="android.view.ViewGroup" content-desc="">
<node index="0" resource-id="" class="android.view.View" content-desc="">
<node index="0" resource-id="" class="android.widget.ImageView" content-desc="marker_generic_unselected_ChIJx0ZL3KwEdkgRbqnmC8H0RA8" />
</node>
</node>
<node index="1" resource-id="" class="android.view.ViewGroup" content-desc="">
<node index="0" resource-id="" class="android.view.View" content-desc="">
<node index="0" resource-id="" class="android.widget.ImageView" content-desc="marker_generic_unselected_ChIJFZCSWqYEdkgRrIou3nanh70" />
</node>
</node>
</node>
<node index="1" resource-id="" class="android.widget.FrameLayout" content-desc="">
<node index="0" resource-id="" class="android.view.View" content-desc="Google Map">
<node index="0" resource-id="" class="android.view.View" content-desc="Map Marker" />
<node index="1" resource-id="" class="android.view.View" content-desc="Map Marker" />
</node>
<node index="1" resource-id="" class="android.widget.RelativeLayout" content-desc="" />
<node index="2" resource-id="" class="android.widget.RelativeLayout" content-desc="">
<node index="0" resource-id="" class="android.widget.ImageView" content-desc="" />
</node>
</node>
</node>
</node>
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
<node index="0" resource-id="" class="android.view.View" content-desc="Google Map">
<node index="0" resource-id="" class="android.view.View" content-desc="marker_generic_unselected_ChIJx0ZL3KwEdkgRbqnmC8H0RA8" />
<node index="1" resource-id="" class="android.view.View" content-desc="marker_generic_unselected_ChIJFZCSWqYEdkgRrIou3nanh70" />
</node>
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<ClusterPinResource>()
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 */ }
}