Skip to content

.accessibilityAddTraits(.isHeader) doesn't merge descendants #433

@dfabulich

Description

@dfabulich
Text("This is a heading")
    .padding(16)
    .accessibilityAddTraits(.isHeader)

This doesn't show up as a heading in Android TalkBack, because the heading is applied to the .padding() container, which has no content description, and not to the underlying Text.

You can work around this by rewriting to put the accessibility modifier first, e.g. Text("This is a heading").accessibilityAddTraits(.isHeader).padding(16).

I think it might also work to use composeModifier to add semantics(mergeDescendants: true). (Maybe accessibilityAddTraits should do that as a general rule…?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions