I have the function below which is a Popup wrapping an OutlinedTextField. This function is called the “main” Composable function when boolean variable is true, and the variable is set by a FloatingActionButton.
@Composable
private fun NewObject(
popupWidth: Float,
popupHeight:Float,
focusRequester: FocusRequester,
onClickOutside: () -> Unit,
)
{
var field by remember { mutableStateOf("") }
Popup(
alignment = Alignment.Center,
onDismissRequest = { onClickOutside() },
) {
Column(
Modifier
.width(popupWidth.dp)
.height(popupHeight.dp)
.background(Color.White)
.clip(RoundedCornerShape(4.dp))
horizontalAlignment = Alignment.CenterHorizontally
) {
OutlinedTextField(value = field,
onValueChange = { field = it },
label = { Text("Enter text") },
modifier = Modifier
.focusRequester(focusRequester)
)
}
}
}
However, the OutlinedTextField never gets keyboard focus, even if I use a FocusRequester. The focus always stays with the composables defined in the “main” function. What am I doing wrong?