Skip to content

Commit e8af8f9

Browse files
dsn5ftafohrman
authored andcommitted
[Predictive Back][Search] Fix issue where modal accessibility is not reset after collapsing search view predictively, which caused the screen to appear frozen when using TalkBack
PiperOrigin-RevId: 566750080 (cherry picked from commit 8d83a31)
1 parent 4442635 commit e8af8f9

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

lib/java/com/google/android/material/search/SearchView.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -785,10 +785,23 @@ public TransitionState getCurrentTransitionState() {
785785
}
786786

787787
void setTransitionState(@NonNull TransitionState state) {
788+
setTransitionState(state, /* updateModalForAccessibility= */ true);
789+
}
790+
791+
private void setTransitionState(
792+
@NonNull TransitionState state, boolean updateModalForAccessibility) {
788793
if (currentTransitionState.equals(state)) {
789794
return;
790795
}
791796

797+
if (updateModalForAccessibility) {
798+
if (state == TransitionState.SHOWN) {
799+
setModalForAccessibility(true);
800+
} else if (state == TransitionState.HIDDEN) {
801+
setModalForAccessibility(false);
802+
}
803+
}
804+
792805
TransitionState previousState = currentTransitionState;
793806
currentTransitionState = state;
794807
Set<TransitionListener> listeners = new LinkedHashSet<>(transitionListeners);
@@ -825,7 +838,6 @@ public void show() {
825838
return;
826839
}
827840
searchViewAnimationHelper.show();
828-
setModalForAccessibility(true);
829841
}
830842

831843
/**
@@ -840,18 +852,16 @@ public void hide() {
840852
return;
841853
}
842854
searchViewAnimationHelper.hide();
843-
setModalForAccessibility(false);
844855
}
845856

846857
/** Updates the visibility of the {@link SearchView} without an animation. */
847858
public void setVisible(boolean visible) {
848859
boolean wasVisible = rootView.getVisibility() == VISIBLE;
849860
rootView.setVisibility(visible ? VISIBLE : GONE);
850861
updateNavigationIconProgressIfNeeded();
851-
if (wasVisible != visible) {
852-
setModalForAccessibility(visible);
853-
}
854-
setTransitionState(visible ? TransitionState.SHOWN : TransitionState.HIDDEN);
862+
setTransitionState(
863+
visible ? TransitionState.SHOWN : TransitionState.HIDDEN,
864+
/* updateModalForAccessibility= */ wasVisible != visible);
855865
}
856866

857867
private void updateNavigationIconProgressIfNeeded() {

0 commit comments

Comments
 (0)