Skip to content

Expose clickable list items as buttons to screen readers - #8320

Open
bmarty wants to merge 7 commits into
developfrom
feature/bma/listItemButtonRole
Open

bmarty wants to merge 7 commits into
developfrom
feature/bma/listItemButtonRole

Conversation

@bmarty

@bmarty bmarty commented Dec 2, 2026

Copy link
Copy Markdown
Member

Content

  • ListItem with onClick now exposes Role.Button (except when it contains a Checkbox, Switch or RadioButton, which already expose their own role).
  • List items in bottom sheets that used Modifier.clickable now use onClick: avatar actions, attachment sources, message actions and room list context menu.

Motivation and context

Part of #8291 (finding 4.4, room list context menu) and #8292 (avatar action sheet; the avatar picker itself is handled in #8318).

Screen readers only announced a generic hint on these items, without a role.

Screenshots / GIFs

No visual change.

Tests

  • Added ListItemTest for the roles.
  • Unit tests, ktlint and detekt pass on the touched modules.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • I am aware of the etiquette.
  • This PR was made with the help of AI:
    • Yes. In this case, please get the PR reviewed by an AI (e.g. a GitHub AI reviewer, or /code-review run in a fresh session) before requesting a human review.
    • No.
  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly defines what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

🤖 Generated with Claude Code

bmarty and others added 2 commits December 2, 2026 11:46
A clickable ListItem used `Modifier.clickable` without a role, so screen readers only announced a generic "Double tap to activate" hint.
Set `Role.Button` on the clickable, except when the item contains a Checkbox, Switch or RadioButton, whose role is already provided by the toggleable / selectable modifier.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
These ListItems were made clickable with `Modifier.clickable`, bypassing the ListItem `onClick` parameter, so they were not exposed as buttons to accessibility services.
Use `onClick` in the avatar action, attachment source, message action and room list context menu bottom sheets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bmarty
bmarty requested a review from a team as a code owner December 2, 2026 11:02
@bmarty
bmarty requested review from jmartinesp and removed request for a team December 2, 2026 11:02
@bmarty bmarty added the PR-Bugfix For bug fix label Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/wiFqz7

@jmartinesp jmartinesp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I found a possible issue. Also, a suggestion, although I'm not sure how feasible it is.

.clickable(enabled = enabled || alwaysClickable, onClick = onClick)
.clickable(
enabled = enabled || alwaysClickable,
role = (trailingContent ?: leadingContent).clickableRole(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is wrong. If you have a list items with a leading content that's a checkbox and a trailing one that's an icon, the icon one will take precedence and you'll get a Button role. Maybe adding some extra tests for these cases would help?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is no occurrence in the code, but good catch since this can happen in the future. I have updated the code

Comment on lines +157 to +161
.clickable(
enabled = enabled || alwaysClickable,
role = (trailingContent ?: leadingContent).clickableRole(),
onClick = onClick,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not new, but couldn't we merge this with withAccessibilityModifier, maybe?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, also I have renamed the method now that is handle the onClick parameter.

bmarty and others added 2 commits December 2, 2026 14:36
The role was computed from `trailingContent ?: leadingContent`, so a list item with a leading Checkbox or RadioButton and a trailing Icon was exposed as a button, without its checked or selected state.
Look for a Checkbox, Switch or RadioButton in the trailing content then in the leading content, and merge the clickable modifier into `withAccessibilityModifier` so that the item only has one click modifier.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The function now also makes the list item clickable, so the old name was misleading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jmartinesp jmartinesp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. I'm approving, with a couple of nits:

  1. alwaysClickable is ignored when the row's control is disabled: with a disabled switch, checkbox or radio button, tapping does nothing even with alwaysClickable = true, which contradicts its docs. That said, I don't think any existing code uses this.
  2. Controls on non-clickable rows with onClick = null, a switch, checkbox or radio button row still gets an enabled toggle. TalkBack says "double tap to toggle", and double-tapping does nothing. This was already the case before, but it would be nice to fix it.

bmarty and others added 2 commits December 2, 2026 15:09
A list item with `alwaysClickable = true` was not clickable when its Checkbox, Switch or RadioButton was disabled, contrary to the documentation of the parameter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A list item with a Checkbox, Switch or RadioButton and no `onClick` still had an enabled toggleable or selectable modifier, so TalkBack announced "Double tap to toggle" although nothing happened.
Only expose the role and the state of the control in this case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bmarty bmarty added Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. and removed Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. labels Dec 2, 2026
@github-actions github-actions Bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Dec 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Bugfix For bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants