Skip to content

Clustering: Missing contentDescription on the clustering pins #683

@PremyslTalich

Description

@PremyslTalich

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

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 */ }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions