Skip to content

Commit ac1a000

Browse files
pekingmeleticiarossi
authored andcommitted
[ToggleButtonGroup] Fixed incorrect A11y class name in child button added in single selection group.
PiperOrigin-RevId: 666950537
1 parent 2901dca commit ac1a000

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/java/com/google/android/material/button/MaterialButtonToggleGroup.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,13 +387,17 @@ public void setSingleSelection(boolean singleSelection) {
387387
}
388388

389389
private void updateChildrenA11yClassName() {
390+
String className = getChildrenA11yClassName();
390391
for (int i = 0; i < getChildCount(); i++) {
391-
String className =
392-
singleSelection ? RadioButton.class.getName() : ToggleButton.class.getName();
393392
getChildButton(i).setA11yClassName(className);
394393
}
395394
}
396395

396+
@NonNull
397+
private String getChildrenA11yClassName() {
398+
return singleSelection ? RadioButton.class.getName() : ToggleButton.class.getName();
399+
}
400+
397401
/**
398402
* Sets whether we prevent all child buttons from being deselected.
399403
*
@@ -517,6 +521,7 @@ private void setupButtonChild(@NonNull MaterialButton buttonChild) {
517521
buttonChild.setMaxLines(1);
518522
buttonChild.setEllipsize(TruncateAt.END);
519523
buttonChild.setCheckable(true);
524+
buttonChild.setA11yClassName(getChildrenA11yClassName());
520525

521526
// Enables surface layer drawing for semi-opaque strokes
522527
buttonChild.setShouldDrawSurfaceColorStroke(true);

0 commit comments

Comments
 (0)