Fixed focusing next focusable element after selecting an item
This commit is contained in:
parent
1a64f24457
commit
e08df3b871
|
@ -13,9 +13,7 @@ import androidx.compose.material.icons.filled.Close
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.FocusDirection
|
import androidx.compose.ui.focus.*
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
|
||||||
import androidx.compose.ui.focus.focusRequester
|
|
||||||
import androidx.compose.ui.geometry.Size
|
import androidx.compose.ui.geometry.Size
|
||||||
import androidx.compose.ui.layout.onGloballyPositioned
|
import androidx.compose.ui.layout.onGloballyPositioned
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
|
@ -50,6 +48,7 @@ fun <T> AutocompleteTextField(
|
||||||
Box(Modifier.fillMaxWidth()) {
|
Box(Modifier.fillMaxWidth()) {
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = searchQuery,
|
value = searchQuery,
|
||||||
|
singleLine = true,
|
||||||
onValueChange = { query ->
|
onValueChange = { query ->
|
||||||
searchQuery = query
|
searchQuery = query
|
||||||
onValueChange(null)
|
onValueChange(null)
|
||||||
|
@ -88,7 +87,8 @@ fun <T> AutocompleteTextField(
|
||||||
suggestions = emptyList()
|
suggestions = emptyList()
|
||||||
expanded = false
|
expanded = false
|
||||||
onValueChange(null)
|
onValueChange(null)
|
||||||
}
|
textFieldFocus.requestFocus()
|
||||||
|
}.focusProperties { canFocus = false }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -113,6 +113,8 @@ fun <T> AutocompleteTextField(
|
||||||
searchQuery = it.invoke(item)
|
searchQuery = it.invoke(item)
|
||||||
}
|
}
|
||||||
expanded = false
|
expanded = false
|
||||||
|
|
||||||
|
textFieldFocus.freeFocus()
|
||||||
focusManager.moveFocus(FocusDirection.Down)
|
focusManager.moveFocus(FocusDirection.Down)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
|
|
Loading…
Reference in New Issue