Jetpack Compose Material 3 DatePicker animation glitch when switching from input mode to calendar mode
I want to add a text field with a date picker to my application. I copied the modal date picker implementation from the official documentation.
However, when I run it on my phone—a Pixel 10a running Android 16—I see an animation glitch when switching the date picker from text input mode to calendar mode, as shown in the attached recording.
Does anyone know what might be causing this and how it can be fixed? Alternatively, is there another date picker implementation you would recommend?
@Composable fun MyAppOutlinedDateTextField( modifier: Modifier = Modifier, label: (@Composable () -> Unit)? = null ) { var selectedDate by remember { mutableStateOf<Long?>(null) } var showModal by remember { mutableStateOf(false) } OutlinedTextField( value = selectedDate?.let { convertMillisToDate(it) } ?: "", onValueChange = { }, label = label, placeholder = { Text("MM/DD/YYYY") }, trailingIcon = { Icon(Icons.Default.DateRange, contentDescription = "Select date") }, modifier = modifier .fillMaxWidth() .pointerInput(selectedDate) { awaitEachGesture { // Modifier.clickable doesn't work for text fields, so we use Modifier.pointerInput // in the Initial pass to observe events before the text field consumes them // in the Main pass. awaitFirstDown(pass = PointerEventPass.Initial) val upEvent = waitForUpOrCancellation(pass = PointerEventPass.Initial) if (upEvent != null) { showModal = true } } } ) if (showModal) { DatePickerModal(onDateSelected = { selectedDate = it }, onDismiss = { showModal = false }) } }
@Composable fun DatePickerModal( onDateSelected: (Long?) -> Unit, onDismiss: () -> Unit ) { val datePickerState = rememberDatePickerState() DatePickerDialog( onDismissRequest = onDismiss, confirmButton = { TextButton(onClick = { onDateSelected(datePickerState.selectedDateMillis) onDismiss() }) { Text("OK") } }, dismissButton = { TextButton(onClick = onDismiss) { Text("Cancel") } } ) { DatePicker(state = datePickerState) } }
composeBom = "2026.05.01" androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } androidx-material3 = { group = "androidx.compose.material3", name = "material3" }