Skip to content

Commit

Permalink
[SearchView][Predictive Back] Fix issue where predictive back is not …
Browse files Browse the repository at this point in the history
…enabled in SearchView after rotating the screen or restarting the activity when the SearchView is already expanded

Resolves #3594
Resolves #3604

PiperOrigin-RevId: 568869369
  • Loading branch information
dsn5ft committed Oct 2, 2023
1 parent 8312162 commit a51561d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/java/com/google/android/material/search/SearchView.java
Expand Up @@ -564,6 +564,7 @@ public void setupWithSearchBar(@Nullable SearchBar searchBar) {
}
updateNavigationIconIfNeeded();
setUpBackgroundViewElevationOverlay();
updateListeningForBackCallbacks(getCurrentTransitionState());
}

/**
Expand Down Expand Up @@ -814,6 +815,10 @@ private void setTransitionState(
listener.onStateChanged(this, previousState, state);
}

updateListeningForBackCallbacks(state);
}

private void updateListeningForBackCallbacks(@NonNull TransitionState state) {
// Only automatically handle back if we have a search bar to collapse to, and if back handling
// is enabled for the SearchView.
if (searchBar != null && backHandlingEnabled) {
Expand Down

0 comments on commit a51561d

Please sign in to comment.