Skip to content

Commit ef95e93

Browse files
imhappihunterstich
authored andcommitted
[SearchView] Set touchscreenBlocksFocus to false to enable keyboard navigation between searchview
PiperOrigin-RevId: 775363522
1 parent 1ee0768 commit ef95e93

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ public SearchView(@NonNull Context context, @Nullable AttributeSet attrs, int de
235235
setUpClearButton();
236236
setUpContentOnTouchListener();
237237
setUpInsetListeners();
238+
239+
// Necessary to enable keyboard navigation to the searchview contents due to toolbar being a
240+
// keyboard navigation cluster from API 26+
241+
setToolbarTouchscreenBlocksFocus(false);
238242
}
239243

240244
@Override
@@ -986,9 +990,9 @@ public void setModalForAccessibility(boolean isSearchViewModal) {
986990
}
987991

988992
/**
989-
* Sets the 'touchscreenBlocksFocus' attribute of the nested toolbar. The attribute defaults to
990-
* 'true' for API level 26+. We need to set it to 'false' if keyboard navigation is needed for the
991-
* search results.
993+
* Sets the 'touchscreenBlocksFocus' attribute of the nested toolbar. This is set to 'false' by
994+
* default, which allows keyboard navigation between the search view toolbar and the search
995+
* results.
992996
*/
993997
public void setToolbarTouchscreenBlocksFocus(boolean touchscreenBlocksFocus) {
994998
toolbar.setTouchscreenBlocksFocus(touchscreenBlocksFocus);

0 commit comments

Comments
 (0)