material-components-android
material-components-android copied to clipboard
[MaterialDatePicker] (Compose) _Today_ is not visually disabled even if it's outside of selectable range
Description: If I build a material date picker with selectable range of today+1 day, whatever, then today day on the picker has no indication that it's not selectable. Here, Aug 19 is not selectable as per picker range, and disabledDayContentColor is red:
Expected behavior: Not clickable elements are visually disabled
Source code:
@Composable
internal fun dayContentColor(
isToday: Boolean,
selected: Boolean,
inRange: Boolean,
enabled: Boolean
): State<Color> {
val target =
when {
selected && enabled -> selectedDayContentColor
selected && !enabled -> disabledSelectedDayContentColor
inRange && enabled -> dayInSelectionRangeContentColor
inRange && !enabled -> disabledDayContentColor
isToday -> todayContentColor
enabled -> dayContentColor
else -> disabledDayContentColor
}
return if (inRange) {
rememberUpdatedState(target)
} else {
// Animate the content color only when the day is not in a range.
animateColorAsState(target, tween(durationMillis = MotionTokens.DurationShort2.toInt()))
}
}
In the source the first two clauses are false because today is not selected, following two are also false because it's not in selectable range either. But isToday is true so the picked color is todayContentColor even though the day is also not enabled.
Minimal sample app repro: trivially reproducible
Android API version: Api 34
Material Library version: Compose dev.chrisbanes.compose:compose-bom:2024.08.00-alpha01
Device: emulator
To help us triage faster, please check to make sure you are using the latest version of the library.
We also happily accept pull requests.