Skip to content

Commit

Permalink
[ToggleButtonGroup] Fixed incorrect A11y class name in child button a…
Browse files Browse the repository at this point in the history
…dded in single selection group.

PiperOrigin-RevId: 666950537
  • Loading branch information
pekingme authored and leticiarossi committed Aug 27, 2024
1 parent 2901dca commit ac1a000
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,17 @@ public void setSingleSelection(boolean singleSelection) {
}

private void updateChildrenA11yClassName() {
String className = getChildrenA11yClassName();
for (int i = 0; i < getChildCount(); i++) {
String className =
singleSelection ? RadioButton.class.getName() : ToggleButton.class.getName();
getChildButton(i).setA11yClassName(className);
}
}

@NonNull
private String getChildrenA11yClassName() {
return singleSelection ? RadioButton.class.getName() : ToggleButton.class.getName();
}

/**
* Sets whether we prevent all child buttons from being deselected.
*
Expand Down Expand Up @@ -517,6 +521,7 @@ private void setupButtonChild(@NonNull MaterialButton buttonChild) {
buttonChild.setMaxLines(1);
buttonChild.setEllipsize(TruncateAt.END);
buttonChild.setCheckable(true);
buttonChild.setA11yClassName(getChildrenA11yClassName());

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

0 comments on commit ac1a000

Please sign in to comment.