Skip to content

Commit

Permalink
[Chip] Fix close icon focus ripple
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 708446508
  • Loading branch information
imhappi committed Dec 23, 2024
1 parent 59de693 commit a7ff8c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/java/com/google/android/material/chip/Chip.java
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,8 @@ protected void getVisibleVirtualViews(@NonNull List<Integer> virtualViewIds) {
protected void onVirtualViewKeyboardFocusChanged(int virtualViewId, boolean hasFocus) {
if (virtualViewId == CLOSE_ICON_VIRTUAL_ID) {
closeIconFocused = hasFocus;
}
if (chipDrawable.refreshCloseIconFocus(closeIconFocused)) {
refreshDrawableState();
}
}
Expand Down
8 changes: 8 additions & 0 deletions lib/java/com/google/android/material/chip/ChipDrawable.java
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,14 @@ public void setTextColor(@Nullable ColorStateList color) {
}
}

boolean refreshCloseIconFocus(boolean closeIconFocused) {
boolean changed = false;
if (closeIcon != null) {
changed = setCloseIconState(closeIconFocused ? new int[] {android.R.attr.state_pressed, android.R.attr.state_enabled} : DEFAULT_STATE);
}
return changed;
}

/** Delegate interface to be implemented by Views that own a ChipDrawable. */
public interface Delegate {

Expand Down

0 comments on commit a7ff8c9

Please sign in to comment.