skiptools / skiptools/skip-ui

`.accessibilityAddTraits(.isHeader)` doesn't merge descendants

Open
#433 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
330
Forks
76
Avg merge
3h 6m
Merged PRs (30d)
1

Description

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…?)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the accessibilityAddTraits entry point and compare its behavior with the composeModifier workaround described in the issue. Confirm how the modifier is applied around padding and what is exposed to Android TalkBack; done means the example is recognized as a heading without requiring the modifier to precede padding.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
accessibility, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.