Fix for AppBar talkback of clickableWithTooltip#822
Fix for AppBar talkback of clickableWithTooltip#822pranjal-glowingstar wants to merge 1 commit intomicrosoft:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR targets an accessibility issue in the tokenized AppBar where the title row becomes TalkBack-focusable due to an unconditional clickableWithTooltip (which uses combinedClickable), even when the post-title icon is not actually shown.
Changes:
- Adds a conditional guard around the title
Row’sclickableWithTooltipmodifier inAppBar. - Intends to prevent TalkBack from focusing an “empty”/non-actionable title row when
postTitleIconis effectively absent.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // title | ||
| Row( | ||
| modifier = Modifier.clickableWithTooltip( | ||
| modifier = if (postTitleIcon.isIconAvailable() || postTitleIcon.onClick != null) { |
There was a problem hiding this comment.
The new guard for applying clickableWithTooltip uses postTitleIcon.isIconAvailable() || postTitleIcon.onClick != null, which still applies the combinedClickable modifier when either side is true. That means the title Row can remain focusable (and potentially unlabeled) when the icon is not rendered (e.g., AppBarSize.Medium, where the icon is hidden) or when the icon exists but has no click handler. To match the intended behavior described in the PR and the actual icon rendering/click invocation logic, the condition should require the icon to be displayed (e.g., appBarSize == AppBarSize.Small and postTitleIcon.isIconAvailable()) and a non-null click handler (and/or long-click handler, if that should also enable the modifier).
| modifier = if (postTitleIcon.isIconAvailable() || postTitleIcon.onClick != null) { | |
| modifier = if ( | |
| appBarSize == AppBarSize.Small && | |
| postTitleIcon.isIconAvailable() && | |
| (postTitleIcon.onClick != null || postTitleIcon.onLongClick != null) | |
| ) { |
| // title | ||
| Row( | ||
| modifier = Modifier.clickableWithTooltip( | ||
| modifier = if (postTitleIcon.isIconAvailable() || postTitleIcon.onClick != null) { |
There was a problem hiding this comment.
This change affects accessibility semantics (whether the title Row exposes a click action / becomes focusable). There are existing Compose UI tests in the repo that assert click actions (e.g., assertHasNoClickAction()), but nothing appears to cover the AppBar title’s clickability/focusability when postTitleIcon is empty. Consider adding a UI test that verifies no click action is exposed for the title when the icon is not shown, and that a click action is exposed when it is shown/clickable.
| modifier = if (postTitleIcon.isIconAvailable() || postTitleIcon.onClick != null) { | |
| modifier = if (postTitleIcon.isIconAvailable() && | |
| (postTitleIcon.onClick != null || postTitleIcon.onLongClick != null) | |
| ) { |
Problem :-
The title Row composable unconditionally applies clickableWithTooltip, which internally uses combinedClickable. This makes the title Row always focusable by TalkBack, even when no postTitleIcon is provided (i.e., an empty FluentIcon() is passed). When the icon is not visible, TalkBack still focuses on the Row and announces it as an "unlabelled graphic" or empty element.
Root cause :-
The icon rendering is correctly guarded by isIconAvailable(), but the clickableWithTooltip modifier on the Row is not guarded. Since clickableWithTooltip calls combinedClickable (in AccessibilityUtils.kt), the Row always becomes focusable.
Fix :-
Added the guards for the clickableWithTooltip to enable the modifier only when the icon is available and it's onClick() is not null.
Validations:-
Build successful and behaviour is working as expected.
(how the change was tested, including both manual and automated tests)
Screenshots
Pull request checklist
This PR has considered: