Skip to content

Commit 968e035

Browse files
paulfthomasimhappi
authored andcommitted
[BottomAppBar][Catalog][a11y] Request focus on search menu when showing
PiperOrigin-RevId: 470727992
1 parent 6e6c53a commit 968e035

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

catalog/java/io/material/catalog/bottomappbar/BottomAppBarMainDemoFragment.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import io.material.catalog.R;
2020

21+
import android.annotation.SuppressLint;
2122
import android.os.Bundle;
2223
import androidx.appcompat.app.AppCompatActivity;
2324
import androidx.appcompat.widget.Toolbar;
@@ -184,6 +185,7 @@ private void setUpBottomAppBarShapeAppearance() {
184185
babBackground.getShapeAppearanceModel().toBuilder().setTopEdge(topEdge).build());
185186
}
186187

188+
@SuppressLint("NewApi")
187189
protected void setUpBottomDrawer(View view) {
188190
View bottomDrawer = coordinatorLayout.findViewById(R.id.bottom_drawer);
189191
bottomDrawerBehavior = BottomSheetBehavior.from(bottomDrawer);
@@ -193,6 +195,7 @@ protected void setUpBottomDrawer(View view) {
193195
v -> bottomDrawerBehavior.setState(BottomSheetBehavior.STATE_HALF_EXPANDED));
194196
bar.setNavigationIcon(R.drawable.ic_drawer_menu_24px);
195197
bar.replaceMenu(R.menu.demo_primary);
198+
bar.getMenu().findItem(R.id.menu_search).getActionView().requestFocus();
196199
}
197200

198201
private void showSnackbar(CharSequence text) {

catalog/java/io/material/catalog/bottomappbar/res/menu/demo_primary.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<menu xmlns:android="http://schemas.android.com/apk/res/android"
1919
xmlns:app="http://schemas.android.com/apk/res-auto">
2020
<item
21+
android:id="@+id/menu_search"
2122
android:icon="@drawable/ic_search_24px"
2223
android:title="@string/cat_bottomappbar_search"
2324
app:showAsAction="ifRoom"/>

0 commit comments

Comments
 (0)