Hi, I am playing with Dialog and vertical scroll, ...
# compose
a
Hi, I am playing with Dialog and vertical scroll, when I click a button inside Dialog, it scrolls to top. How can I keep the scroll position intact on button click?
Copy code
@Composable
fun AddTaskDialog(onDismissRequest: () -> Unit) {
    Dialog(onDismissRequest = onDismissRequest) {
        AddTaskDialogContent()
    }
}

@Composable
fun AddTaskDialogContent() {
    val taskTitle = remember {
        mutableStateOf(TextFieldValue())
    }
    val taskDescription = remember {
        mutableStateOf(TextFieldValue())
    }

    Surface(
        Modifier
            .fillMaxWidth()
    ) {
        Column(
            Modifier
                .padding(16.dp)
                .verticalScroll(rememberScrollState()),
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            Text(
                text = "Add your task!",
                fontSize = 25.sp
            )
            OutlinedTextField(value = taskTitle.value,
                onValueChange = { taskTitle.value = it },
                label = { Text(text = "Title") }
            )
            OutlinedTextField(value = taskDescription.value,
                onValueChange = { taskDescription.value = it },
                label = { Text(text = "Description") }
            )
            Spacer(modifier = Modifier.height(206.dp))
            Button(onClick = {
                Log.d("Adi", "AddTaskDialogContent: Add Task Clicked!")
            }) {
                Text(text = "Add Task")
            }
        }
    }
}
It scrolls to top on clicking Add Task button
The above issue has been fixed in beta08 🎉