1515 */
1616package com.kanyidev.searchable_dropdown
1717
18- import androidx.compose.foundation.clickable
1918import androidx.compose.foundation.interaction.MutableInteractionSource
2019import androidx.compose.foundation.interaction.PressInteraction
2120import androidx.compose.foundation.layout.Arrangement
@@ -52,7 +51,6 @@ import androidx.compose.ui.platform.LocalDensity
5251import androidx.compose.ui.platform.LocalSoftwareKeyboardController
5352import androidx.compose.ui.unit.Dp
5453import androidx.compose.ui.unit.dp
55- import kotlinx.coroutines.InternalCoroutinesApi
5654import kotlinx.coroutines.flow.collect
5755
5856/* *
@@ -76,7 +74,7 @@ import kotlinx.coroutines.flow.collect
7674 * @param onSearchTextFieldClicked use this if you are having problems with the keyboard showing, use this to show keyboard on your side
7775 */
7876
79- @OptIn(ExperimentalComposeUiApi ::class , InternalCoroutinesApi :: class )
77+ @OptIn(ExperimentalComposeUiApi ::class )
8078@Composable
8179fun <T > SearchableExpandedDropDownMenu (
8280 modifier : Modifier = Modifier ,
@@ -192,10 +190,7 @@ fun <T> SearchableExpandedDropDownMenu(
192190 OutlinedTextField (
193191 modifier = modifier
194192 .fillMaxWidth()
195- .padding(16 .dp)
196- .clickable {
197- onSearchTextFieldClicked()
198- },
193+ .padding(16 .dp),
199194 value = searchedOption,
200195 onValueChange = { selectedSport ->
201196 searchedOption = selectedSport
@@ -212,6 +207,17 @@ fun <T> SearchableExpandedDropDownMenu(
212207 placeholder = {
213208 Text (text = " Search" )
214209 },
210+ interactionSource = remember { MutableInteractionSource () }
211+ .also { interactionSource ->
212+ LaunchedEffect (interactionSource) {
213+ keyboardController?.show()
214+ interactionSource.interactions.collect {
215+ if (it is PressInteraction .Release ) {
216+ onSearchTextFieldClicked()
217+ }
218+ }
219+ }
220+ },
215221 )
216222
217223 val items = if (filteredItems.isEmpty()) {
0 commit comments