material-components / material-components/material-components-android
[SearchView] when the SearchView is collapsed, the soft keyboard would appear when typing
@hunterstich ci sta già lavorando.
Dal 2/1/2025.
- Lingua principale
- Java
- Stelle
- 17.4k
- Fork
- 3.2k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Description: Full description of issue here
- Have a SearchView used in the app. Either run via a mirrored way (using ScrCpy or the IDE), or run on emulator
- Try to type using the PC's keyboard right on beginning. Nothing occurs, as it should
- Open the SearchView, and then type. The soft keyboard appears as soon as you open the SearchView (as it should). You might see other issues such as the keyboard going away for some reason (bug!).
- Now close the SearchView, notice the soft-keyboard also goes away.
- Again type.
The bug is that the soft-keyboard appears again, as if you can type...
Expected behavior: Screenshots and/or description of expected behavior
The keyboard should stay when I can type to something (and shouldn't close by itself), and it shouldn't appear when I start typing into nothing.
Source code: The code snippet which is causing this issue
override fun onCreateOptionsMenu(menu: Menu): Boolean {
// Inflate the menu; this adds items to the action bar if it is present.
menuInflater.inflate(R.menu.menu_main, menu)
menu.findItem(R.id.menuItem_search)
.setOnActionExpandListener(object : OnActionExpandListener {
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
Log.d("AppLog", "onMenuItemActionExpand")
return true
}
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
Log.d("AppLog", "onMenuItemActionCollapse")
return true
}
})
return true
}
res/menu/menu_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.lb.myapplication.MainActivity">
<item
android:id="@+id/menuItem_search"
android:icon="@android:drawable/ic_search_category_default" android:title="search"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="always|collapseActionView" />
<item
android:id="@+id/action_settings" android:orderInCategory="100"
android:title="@string/action_settings" app:showAsAction="never" />
</menu>
Minimal sample app repro: Please consider attaching a minimal sample app that reproduces the issue. This will help narrow down the conditions required for reproducing the issue, and it will speed up the bug fix process. You may attach a zip file of the sample app or link to a GitHub repo that contains the sample app.
Attached, together with a video:
Android API version: Android API version here
35 (Android 15)
Material Library version: Material Android Library version you are using here (e.g., 1.1.0-alpha07)
implementation("androidx.core:core-ktx:1.16.0-alpha01")
implementation("com.google.android.material:material:1.13.0-alpha09")
implementation("androidx.constraintlayout:constraintlayout:2.2.0")
implementation("androidx.navigation:navigation-fragment-ktx:2.8.5")
implementation("androidx.navigation:navigation-ui-ktx:2.8.5")
Device: Device on which the bug was encountered here
Pixel 6 and emulator.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.