Missing Grouping for Composite Components

Id MissingGroupingforCompositeComponents
Summary Composite components are not semantically grouped as a single logical element
Severity N/A
Category Assistive Technologies / Custom Views and Implementation
Affects Resource files and Kotlin and Java files
Implementation Manual testing – although some static analysis is possible (e.g., flagging containers with multiple children), determining if semantic grouping is required is context-dependent and best validated through manual accessibility testing.

Symptom

Composite UI elements lack proper semantic grouping implementation using Modifier.semantics or Modifier.clearAndSetSemantics, causing individual child elements to be exposed separately to accessibility services instead of being presented as unified, meaningful announcements.

Rationale

Creates a fragmented and confusing experience for assistive technology users who must navigate through multiple separate elements to understand one logical piece of information, significantly reducing navigation efficiency and comprehension when content should be announced as a cohesive unit.

Examples

XML Layout Example

<!-- No semantic grouping; each child announced separately -->
<LinearLayout>
    <!-- Missing: android:contentDescription to group info, e.g.: -->
    <!-- android:contentDescription="Wireless Headphones, $99.99, 4.5 stars" -->
    <TextView android:text="Wireless Headphones" />
    <TextView android:text="$99.99" />
    <RatingBar android:rating="4.5" />
</LinearLayout>

Kotlin Code Example

class ProductCardView(context: Context) : LinearLayout(context) {
    init {
        addView(TextView(context).apply { text = "Product Name" })
        addView(TextView(context).apply { text = "Price" })
        addView(RatingBar(context))
        // Each child is announced separately

        // Missing parent contentDescription to group info
        // contentDescription = "Product Name, Price, 4.5 stars"
        // Children can be set importantForAccessibility = NO if needed
    }
}

GitHub issues under this tag