Skip to content

Commit

Permalink
[Tab][a11y] Fix title being announced twice when there's a badge in T…
Browse files Browse the repository at this point in the history
…alkBack mode.

Resolves #3985

PiperOrigin-RevId: 600854666
(cherry picked from commit ef60931)
  • Loading branch information
leticiarossi authored and hunterstich committed Mar 21, 2024
1 parent 3a5bb7d commit aaa7034
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/java/com/google/android/material/tabs/TabLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -2678,12 +2678,10 @@ public void setSelected(final boolean selected) {
@Override
public void onInitializeAccessibilityNodeInfo(@NonNull AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
AccessibilityNodeInfoCompat infoCompat = AccessibilityNodeInfoCompat.wrap(info);
if (badgeDrawable != null && badgeDrawable.isVisible()) {
CharSequence customContentDescription = getContentDescription();
info.setContentDescription(
customContentDescription + ", " + badgeDrawable.getContentDescription());
infoCompat.setContentDescription(badgeDrawable.getContentDescription());
}
AccessibilityNodeInfoCompat infoCompat = AccessibilityNodeInfoCompat.wrap(info);
infoCompat.setCollectionItemInfo(
CollectionItemInfoCompat.obtain(
/* rowIndex= */ 0,
Expand Down

0 comments on commit aaa7034

Please sign in to comment.