Skip to content

Commit

Permalink
[DropdownMenu][a11y] Fix incorrect state
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 502659684
  • Loading branch information
paulfthomas authored and raajkumars committed Jan 18, 2023
1 parent 4bd5e61 commit 3b99749
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityEventCompat;
import androidx.core.view.accessibility.AccessibilityManagerCompat.TouchExplorationStateChangeListener;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import com.google.android.material.animation.AnimationUtils;
Expand Down Expand Up @@ -230,13 +231,21 @@ public void onInitializeAccessibilityNodeInfo(
}
}

@SuppressLint("WrongConstant")
@Override
public void onPopulateAccessibilityEvent(View host, @NonNull AccessibilityEvent event) {
if (!accessibilityManager.isEnabled() || isEditable(autoCompleteTextView)) {
return;
}
// TODO(b/256138189): Find better workaround, back gesture should call
// AutoCompleteTextView.OnDismissListener.
boolean invalidState =
event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED
&& isEndIconChecked
&& !autoCompleteTextView.isPopupShowing();
// If dropdown is non editable, layout click is what triggers showing/hiding the popup
// list. Otherwise, arrow icon alone is what triggers it.
if (event.getEventType() == TYPE_VIEW_CLICKED
&& accessibilityManager.isEnabled()
&& !isEditable(autoCompleteTextView)) {
if (event.getEventType() == TYPE_VIEW_CLICKED || invalidState) {
showHideDropdown();
updateDropdownPopupDirty();
}
Expand Down

0 comments on commit 3b99749

Please sign in to comment.